OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "content/public/renderer/media_stream_renderer_factory.h" | 7 #include "content/public/renderer/media_stream_renderer_factory.h" |
8 #include "content/renderer/media/webmediaplayer_ms.h" | 8 #include "content/renderer/media/webmediaplayer_ms.h" |
9 #include "content/renderer/media/webmediaplayer_ms_compositor.h" | 9 #include "content/renderer/media/webmediaplayer_ms_compositor.h" |
10 #include "content/renderer/render_frame_impl.h" | 10 #include "content/renderer/render_frame_impl.h" |
11 #include "media/base/test_helpers.h" | 11 #include "media/base/test_helpers.h" |
12 #include "media/base/video_frame.h" | 12 #include "media/base/video_frame.h" |
13 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | 13 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" |
14 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" | 14 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" |
15 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" | 15 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
19 enum class FrameType { | 19 enum class FrameType { |
20 NORMAL_FRAME = 0, | 20 NORMAL_FRAME = 0, |
21 BROKEN_FRAME = -1, | 21 BROKEN_FRAME = -1, |
22 TEST_BRAKE = -2, // Signal to pause message loop. | 22 TEST_BRAKE = -2, // Signal to pause message loop. |
23 MIN_TYPE = TEST_BRAKE | 23 MIN_TYPE = TEST_BRAKE |
24 }; | 24 }; |
25 | 25 |
26 using TestFrame = std::pair<FrameType, scoped_refptr<media::VideoFrame>>; | 26 using TestFrame = std::pair<FrameType, scoped_refptr<media::VideoFrame>>; |
27 | 27 |
28 static const int kOddSizeOffset = 3; | 28 static const int kOddSizeOffset = 3; |
| 29 static const int kStandardWidth = 320; |
| 30 static const int kStandardHeight = 240; |
29 | 31 |
30 class FakeWebMediaPlayerDelegate | 32 class FakeWebMediaPlayerDelegate |
31 : public media::WebMediaPlayerDelegate, | 33 : public media::WebMediaPlayerDelegate, |
32 public base::SupportsWeakPtr<FakeWebMediaPlayerDelegate> { | 34 public base::SupportsWeakPtr<FakeWebMediaPlayerDelegate> { |
33 public: | 35 public: |
34 FakeWebMediaPlayerDelegate() {} | 36 FakeWebMediaPlayerDelegate() {} |
35 ~FakeWebMediaPlayerDelegate() override { | 37 ~FakeWebMediaPlayerDelegate() override { |
36 DCHECK(!observer_); | 38 DCHECK(!observer_); |
37 DCHECK(is_gone_); | 39 DCHECK(is_gone_); |
38 } | 40 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 128 |
127 // Implementation of VideoFrameProvider | 129 // Implementation of VideoFrameProvider |
128 void Start() override; | 130 void Start() override; |
129 void Stop() override; | 131 void Stop() override; |
130 void Play() override; | 132 void Play() override; |
131 void Pause() override; | 133 void Pause() override; |
132 | 134 |
133 // Methods for test use | 135 // Methods for test use |
134 void QueueFrames(const std::vector<int>& timestamps_or_frame_type, | 136 void QueueFrames(const std::vector<int>& timestamps_or_frame_type, |
135 bool opaque_frame = true, | 137 bool opaque_frame = true, |
136 bool odd_size_frame = false); | 138 bool odd_size_frame = false, |
| 139 int double_size_index = -1); |
137 bool Started() { return started_; } | 140 bool Started() { return started_; } |
138 bool Paused() { return paused_; } | 141 bool Paused() { return paused_; } |
139 | 142 |
140 private: | 143 private: |
141 ~MockVideoFrameProvider() override {} | 144 ~MockVideoFrameProvider() override {} |
142 | 145 |
143 // Main function that pushes a frame into WebMediaPlayerMS | 146 // Main function that pushes a frame into WebMediaPlayerMS |
144 void InjectFrame(); | 147 void InjectFrame(); |
145 | 148 |
146 // Methods for test use | 149 // Methods for test use |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 187 |
185 void MockVideoFrameProvider::AddFrame( | 188 void MockVideoFrameProvider::AddFrame( |
186 FrameType category, | 189 FrameType category, |
187 const scoped_refptr<media::VideoFrame>& frame) { | 190 const scoped_refptr<media::VideoFrame>& frame) { |
188 frames_.push_back(std::make_pair(category, frame)); | 191 frames_.push_back(std::make_pair(category, frame)); |
189 } | 192 } |
190 | 193 |
191 void MockVideoFrameProvider::QueueFrames( | 194 void MockVideoFrameProvider::QueueFrames( |
192 const std::vector<int>& timestamp_or_frame_type, | 195 const std::vector<int>& timestamp_or_frame_type, |
193 bool opaque_frame, | 196 bool opaque_frame, |
194 bool odd_size_frame) { | 197 bool odd_size_frame, |
195 for (const int token : timestamp_or_frame_type) { | 198 int double_size_index) { |
| 199 gfx::Size standard_size = gfx::Size(kStandardWidth, kStandardHeight); |
| 200 for (size_t i = 0; i < timestamp_or_frame_type.size(); i++) { |
| 201 const int token = timestamp_or_frame_type[i]; |
| 202 if (static_cast<int>(i) == double_size_index) { |
| 203 standard_size = gfx::Size(kStandardWidth * 2, kStandardHeight * 2); |
| 204 } |
196 if (token < static_cast<int>(FrameType::MIN_TYPE)) { | 205 if (token < static_cast<int>(FrameType::MIN_TYPE)) { |
197 CHECK(false) << "Unrecognized frame type: " << token; | 206 CHECK(false) << "Unrecognized frame type: " << token; |
198 return; | 207 return; |
199 } | 208 } |
200 | 209 |
201 if (token < 0) { | 210 if (token < 0) { |
202 AddFrame(static_cast<FrameType>(token), nullptr); | 211 AddFrame(static_cast<FrameType>(token), nullptr); |
203 continue; | 212 continue; |
204 } | 213 } |
205 | 214 |
206 if (token >= 0) { | 215 if (token >= 0) { |
207 gfx::Size natural_size = media::TestVideoConfig::NormalCodedSize(); | 216 gfx::Size frame_size; |
208 if (odd_size_frame) { | 217 if (odd_size_frame) { |
209 natural_size.SetSize(natural_size.width() - kOddSizeOffset, | 218 frame_size.SetSize(standard_size.width() - kOddSizeOffset, |
210 natural_size.height() - kOddSizeOffset); | 219 standard_size.height() - kOddSizeOffset); |
| 220 } else { |
| 221 frame_size.SetSize(standard_size.width(), standard_size.height()); |
211 } | 222 } |
212 auto frame = media::VideoFrame::CreateZeroInitializedFrame( | 223 auto frame = media::VideoFrame::CreateZeroInitializedFrame( |
213 opaque_frame ? media::PIXEL_FORMAT_YV12 : media::PIXEL_FORMAT_YV12A, | 224 opaque_frame ? media::PIXEL_FORMAT_YV12 : media::PIXEL_FORMAT_YV12A, |
214 natural_size, gfx::Rect(natural_size), natural_size, | 225 frame_size, gfx::Rect(frame_size), frame_size, |
215 base::TimeDelta::FromMilliseconds(token)); | 226 base::TimeDelta::FromMilliseconds(token)); |
216 | 227 |
217 frame->metadata()->SetTimeTicks( | 228 frame->metadata()->SetTimeTicks( |
218 media::VideoFrameMetadata::Key::REFERENCE_TIME, | 229 media::VideoFrameMetadata::Key::REFERENCE_TIME, |
219 base::TimeTicks::Now() + base::TimeDelta::FromMilliseconds(token)); | 230 base::TimeTicks::Now() + base::TimeDelta::FromMilliseconds(token)); |
220 | 231 |
221 AddFrame(FrameType::NORMAL_FRAME, frame); | 232 AddFrame(FrameType::NORMAL_FRAME, frame); |
222 continue; | 233 continue; |
223 } | 234 } |
224 } | 235 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 ~WebMediaPlayerMSTest() override {} | 376 ~WebMediaPlayerMSTest() override {} |
366 | 377 |
367 MockVideoFrameProvider* LoadAndGetFrameProvider(bool algorithm_enabled); | 378 MockVideoFrameProvider* LoadAndGetFrameProvider(bool algorithm_enabled); |
368 | 379 |
369 // Implementation of WebMediaPlayerClient | 380 // Implementation of WebMediaPlayerClient |
370 void networkStateChanged() override; | 381 void networkStateChanged() override; |
371 void readyStateChanged() override; | 382 void readyStateChanged() override; |
372 void timeChanged() override {} | 383 void timeChanged() override {} |
373 void repaint() override {} | 384 void repaint() override {} |
374 void durationChanged() override {} | 385 void durationChanged() override {} |
375 void sizeChanged() override {} | 386 void sizeChanged() override; |
376 void playbackStateChanged() override {} | 387 void playbackStateChanged() override {} |
377 void setWebLayer(blink::WebLayer* layer) override; | 388 void setWebLayer(blink::WebLayer* layer) override; |
378 blink::WebMediaPlayer::TrackId addAudioTrack(const blink::WebString& id, | 389 blink::WebMediaPlayer::TrackId addAudioTrack(const blink::WebString& id, |
379 AudioTrackKind, | 390 AudioTrackKind, |
380 const blink::WebString& label, | 391 const blink::WebString& label, |
381 const blink::WebString& language, | 392 const blink::WebString& language, |
382 bool enabled) override { | 393 bool enabled) override { |
383 return 0; | 394 return 0; |
384 } | 395 } |
385 void removeAudioTrack(blink::WebMediaPlayer::TrackId) override {} | 396 void removeAudioTrack(blink::WebMediaPlayer::TrackId) override {} |
(...skipping 26 matching lines...) Expand all Loading... |
412 } | 423 } |
413 | 424 |
414 protected: | 425 protected: |
415 MOCK_METHOD0(DoStartRendering, void()); | 426 MOCK_METHOD0(DoStartRendering, void()); |
416 MOCK_METHOD0(DoStopRendering, void()); | 427 MOCK_METHOD0(DoStopRendering, void()); |
417 | 428 |
418 MOCK_METHOD1(DoSetWebLayer, void(bool)); | 429 MOCK_METHOD1(DoSetWebLayer, void(bool)); |
419 MOCK_METHOD1(DoNetworkStateChanged, | 430 MOCK_METHOD1(DoNetworkStateChanged, |
420 void(blink::WebMediaPlayer::NetworkState)); | 431 void(blink::WebMediaPlayer::NetworkState)); |
421 MOCK_METHOD1(DoReadyStateChanged, void(blink::WebMediaPlayer::ReadyState)); | 432 MOCK_METHOD1(DoReadyStateChanged, void(blink::WebMediaPlayer::ReadyState)); |
| 433 MOCK_METHOD1(CheckSizeChanged, void(gfx::Size)); |
422 | 434 |
423 base::MessageLoop message_loop_; | 435 base::MessageLoop message_loop_; |
424 MockRenderFactory* render_factory_; | 436 MockRenderFactory* render_factory_; |
425 FakeWebMediaPlayerDelegate delegate_; | 437 FakeWebMediaPlayerDelegate delegate_; |
426 WebMediaPlayerMS player_; | 438 WebMediaPlayerMS player_; |
427 WebMediaPlayerMSCompositor* compositor_; | 439 WebMediaPlayerMSCompositor* compositor_; |
428 ReusableMessageLoopEvent message_loop_controller_; | 440 ReusableMessageLoopEvent message_loop_controller_; |
429 | 441 |
430 private: | 442 private: |
431 // Main function trying to ask WebMediaPlayerMS to submit a frame for | 443 // Main function trying to ask WebMediaPlayerMS to submit a frame for |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 compositor_->UpdateCurrentFrame(deadline_min, deadline_max); | 533 compositor_->UpdateCurrentFrame(deadline_min, deadline_max); |
522 auto frame = compositor_->GetCurrentFrame(); | 534 auto frame = compositor_->GetCurrentFrame(); |
523 compositor_->PutCurrentFrame(); | 535 compositor_->PutCurrentFrame(); |
524 } | 536 } |
525 message_loop_.PostDelayedTask( | 537 message_loop_.PostDelayedTask( |
526 FROM_HERE, | 538 FROM_HERE, |
527 base::Bind(&WebMediaPlayerMSTest::RenderFrame, base::Unretained(this)), | 539 base::Bind(&WebMediaPlayerMSTest::RenderFrame, base::Unretained(this)), |
528 base::TimeDelta::FromSecondsD(1.0 / 60.0)); | 540 base::TimeDelta::FromSecondsD(1.0 / 60.0)); |
529 } | 541 } |
530 | 542 |
| 543 void WebMediaPlayerMSTest::sizeChanged() { |
| 544 gfx::Size frame_size = compositor_->GetCurrentSize(); |
| 545 CheckSizeChanged(frame_size); |
| 546 } |
| 547 |
531 TEST_F(WebMediaPlayerMSTest, Playing_Normal) { | 548 TEST_F(WebMediaPlayerMSTest, Playing_Normal) { |
532 // This test sends a bunch of normal frames with increasing timestamps | 549 // This test sends a bunch of normal frames with increasing timestamps |
533 // and verifies that they are produced by WebMediaPlayerMS in appropriate | 550 // and verifies that they are produced by WebMediaPlayerMS in appropriate |
534 // order. | 551 // order. |
535 | 552 |
536 MockVideoFrameProvider* provider = LoadAndGetFrameProvider(true); | 553 MockVideoFrameProvider* provider = LoadAndGetFrameProvider(true); |
537 | 554 |
538 int tokens[] = {0, 33, 66, 100, 133, 166, 200, 233, 266, 300, | 555 int tokens[] = {0, 33, 66, 100, 133, 166, 200, 233, 266, 300, |
539 333, 366, 400, 433, 466, 500, 533, 566, 600}; | 556 333, 366, 400, 433, 466, 500, 533, 566, 600}; |
540 std::vector<int> timestamps(tokens, tokens + sizeof(tokens) / sizeof(int)); | 557 std::vector<int> timestamps(tokens, tokens + sizeof(tokens) / sizeof(int)); |
541 provider->QueueFrames(timestamps); | 558 provider->QueueFrames(timestamps); |
542 | 559 |
543 EXPECT_CALL(*this, DoSetWebLayer(true)); | 560 EXPECT_CALL(*this, DoSetWebLayer(true)); |
544 EXPECT_CALL(*this, DoStartRendering()); | 561 EXPECT_CALL(*this, DoStartRendering()); |
545 EXPECT_CALL(*this, DoReadyStateChanged( | 562 EXPECT_CALL(*this, DoReadyStateChanged( |
546 blink::WebMediaPlayer::ReadyStateHaveMetadata)); | 563 blink::WebMediaPlayer::ReadyStateHaveMetadata)); |
547 EXPECT_CALL(*this, DoReadyStateChanged( | 564 EXPECT_CALL(*this, DoReadyStateChanged( |
548 blink::WebMediaPlayer::ReadyStateHaveEnoughData)); | 565 blink::WebMediaPlayer::ReadyStateHaveEnoughData)); |
| 566 EXPECT_CALL(*this, |
| 567 CheckSizeChanged(gfx::Size(kStandardWidth, kStandardHeight))); |
549 message_loop_controller_.RunAndWaitForStatus( | 568 message_loop_controller_.RunAndWaitForStatus( |
550 media::PipelineStatus::PIPELINE_OK); | 569 media::PipelineStatus::PIPELINE_OK); |
551 testing::Mock::VerifyAndClearExpectations(this); | 570 testing::Mock::VerifyAndClearExpectations(this); |
552 | 571 |
553 EXPECT_CALL(*this, DoSetWebLayer(false)); | 572 EXPECT_CALL(*this, DoSetWebLayer(false)); |
554 EXPECT_CALL(*this, DoStopRendering()); | 573 EXPECT_CALL(*this, DoStopRendering()); |
555 } | 574 } |
556 | 575 |
557 TEST_F(WebMediaPlayerMSTest, Playing_ErrorFrame) { | 576 TEST_F(WebMediaPlayerMSTest, Playing_ErrorFrame) { |
558 // This tests sends a broken frame to WebMediaPlayerMS, and verifies | 577 // This tests sends a broken frame to WebMediaPlayerMS, and verifies |
559 // OnSourceError function works as expected. | 578 // OnSourceError function works as expected. |
560 | 579 |
561 MockVideoFrameProvider* provider = LoadAndGetFrameProvider(false); | 580 MockVideoFrameProvider* provider = LoadAndGetFrameProvider(false); |
562 | 581 |
563 const int kBrokenFrame = static_cast<int>(FrameType::BROKEN_FRAME); | 582 const int kBrokenFrame = static_cast<int>(FrameType::BROKEN_FRAME); |
564 int tokens[] = {0, 33, 66, 100, 133, 166, 200, 233, 266, 300, | 583 int tokens[] = {0, 33, 66, 100, 133, 166, 200, 233, 266, 300, |
565 333, 366, 400, 433, 466, 500, 533, 566, 600, kBrokenFrame}; | 584 333, 366, 400, 433, 466, 500, 533, 566, 600, kBrokenFrame}; |
566 std::vector<int> timestamps(tokens, tokens + sizeof(tokens) / sizeof(int)); | 585 std::vector<int> timestamps(tokens, tokens + sizeof(tokens) / sizeof(int)); |
567 provider->QueueFrames(timestamps); | 586 provider->QueueFrames(timestamps); |
568 | 587 |
569 EXPECT_CALL(*this, DoSetWebLayer(true)); | 588 EXPECT_CALL(*this, DoSetWebLayer(true)); |
570 EXPECT_CALL(*this, DoStartRendering()); | 589 EXPECT_CALL(*this, DoStartRendering()); |
571 EXPECT_CALL(*this, DoReadyStateChanged( | 590 EXPECT_CALL(*this, DoReadyStateChanged( |
572 blink::WebMediaPlayer::ReadyStateHaveMetadata)); | 591 blink::WebMediaPlayer::ReadyStateHaveMetadata)); |
573 EXPECT_CALL(*this, DoReadyStateChanged( | 592 EXPECT_CALL(*this, DoReadyStateChanged( |
574 blink::WebMediaPlayer::ReadyStateHaveEnoughData)); | 593 blink::WebMediaPlayer::ReadyStateHaveEnoughData)); |
575 EXPECT_CALL(*this, DoNetworkStateChanged( | 594 EXPECT_CALL(*this, DoNetworkStateChanged( |
576 blink::WebMediaPlayer::NetworkStateFormatError)); | 595 blink::WebMediaPlayer::NetworkStateFormatError)); |
| 596 EXPECT_CALL(*this, |
| 597 CheckSizeChanged(gfx::Size(kStandardWidth, kStandardHeight))); |
577 message_loop_controller_.RunAndWaitForStatus( | 598 message_loop_controller_.RunAndWaitForStatus( |
578 media::PipelineStatus::PIPELINE_ERROR_NETWORK); | 599 media::PipelineStatus::PIPELINE_ERROR_NETWORK); |
579 testing::Mock::VerifyAndClearExpectations(this); | 600 testing::Mock::VerifyAndClearExpectations(this); |
580 | 601 |
581 EXPECT_CALL(*this, DoSetWebLayer(false)); | 602 EXPECT_CALL(*this, DoSetWebLayer(false)); |
582 EXPECT_CALL(*this, DoStopRendering()); | 603 EXPECT_CALL(*this, DoStopRendering()); |
583 } | 604 } |
584 | 605 |
585 TEST_P(WebMediaPlayerMSTest, PlayThenPause) { | 606 TEST_P(WebMediaPlayerMSTest, PlayThenPause) { |
586 const bool opaque_frame = testing::get<0>(GetParam()); | 607 const bool opaque_frame = testing::get<0>(GetParam()); |
587 const bool odd_size_frame = testing::get<1>(GetParam()); | 608 const bool odd_size_frame = testing::get<1>(GetParam()); |
588 // In the middle of this test, WebMediaPlayerMS::pause will be called, and we | 609 // In the middle of this test, WebMediaPlayerMS::pause will be called, and we |
589 // are going to verify that during the pause stage, a frame gets freezed, and | 610 // are going to verify that during the pause stage, a frame gets freezed, and |
590 // cc::VideoFrameProviderClient should also be paused. | 611 // cc::VideoFrameProviderClient should also be paused. |
591 MockVideoFrameProvider* provider = LoadAndGetFrameProvider(false); | 612 MockVideoFrameProvider* provider = LoadAndGetFrameProvider(false); |
592 | 613 |
593 const int kTestBrake = static_cast<int>(FrameType::TEST_BRAKE); | 614 const int kTestBrake = static_cast<int>(FrameType::TEST_BRAKE); |
594 int tokens[] = {0, 33, 66, 100, 133, kTestBrake, 166, 200, 233, 266, | 615 int tokens[] = {0, 33, 66, 100, 133, kTestBrake, 166, 200, 233, 266, |
595 300, 333, 366, 400, 433, 466, 500, 533, 566, 600}; | 616 300, 333, 366, 400, 433, 466, 500, 533, 566, 600}; |
596 std::vector<int> timestamps(tokens, tokens + sizeof(tokens) / sizeof(int)); | 617 std::vector<int> timestamps(tokens, tokens + sizeof(tokens) / sizeof(int)); |
597 provider->QueueFrames(timestamps, opaque_frame, odd_size_frame); | 618 provider->QueueFrames(timestamps, opaque_frame, odd_size_frame); |
598 | 619 |
599 EXPECT_CALL(*this, DoSetWebLayer(true)); | 620 EXPECT_CALL(*this, DoSetWebLayer(true)); |
600 EXPECT_CALL(*this, DoStartRendering()); | 621 EXPECT_CALL(*this, DoStartRendering()); |
601 EXPECT_CALL(*this, DoReadyStateChanged( | 622 EXPECT_CALL(*this, DoReadyStateChanged( |
602 blink::WebMediaPlayer::ReadyStateHaveMetadata)); | 623 blink::WebMediaPlayer::ReadyStateHaveMetadata)); |
603 EXPECT_CALL(*this, DoReadyStateChanged( | 624 EXPECT_CALL(*this, DoReadyStateChanged( |
604 blink::WebMediaPlayer::ReadyStateHaveEnoughData)); | 625 blink::WebMediaPlayer::ReadyStateHaveEnoughData)); |
| 626 gfx::Size frame_size = |
| 627 gfx::Size(kStandardWidth - (odd_size_frame ? kOddSizeOffset : 0), |
| 628 kStandardHeight - (odd_size_frame ? kOddSizeOffset : 0)); |
| 629 EXPECT_CALL(*this, CheckSizeChanged(frame_size)); |
605 message_loop_controller_.RunAndWaitForStatus( | 630 message_loop_controller_.RunAndWaitForStatus( |
606 media::PipelineStatus::PIPELINE_OK); | 631 media::PipelineStatus::PIPELINE_OK); |
607 testing::Mock::VerifyAndClearExpectations(this); | 632 testing::Mock::VerifyAndClearExpectations(this); |
608 | 633 |
609 // Here we call pause, and expect a freezing frame. | 634 // Here we call pause, and expect a freezing frame. |
610 EXPECT_CALL(*this, DoStopRendering()); | 635 EXPECT_CALL(*this, DoStopRendering()); |
611 player_.pause(); | 636 player_.pause(); |
612 auto prev_frame = compositor_->GetCurrentFrame(); | 637 auto prev_frame = compositor_->GetCurrentFrame(); |
613 message_loop_controller_.RunAndWaitForStatus( | 638 message_loop_controller_.RunAndWaitForStatus( |
614 media::PipelineStatus::PIPELINE_OK); | 639 media::PipelineStatus::PIPELINE_OK); |
(...skipping 17 matching lines...) Expand all Loading... |
632 433, kTestBrake, 466, 500, 533, 566, 600}; | 657 433, kTestBrake, 466, 500, 533, 566, 600}; |
633 std::vector<int> timestamps(tokens, tokens + sizeof(tokens) / sizeof(int)); | 658 std::vector<int> timestamps(tokens, tokens + sizeof(tokens) / sizeof(int)); |
634 provider->QueueFrames(timestamps, opaque_frame, odd_size_frame); | 659 provider->QueueFrames(timestamps, opaque_frame, odd_size_frame); |
635 | 660 |
636 EXPECT_CALL(*this, DoSetWebLayer(true)); | 661 EXPECT_CALL(*this, DoSetWebLayer(true)); |
637 EXPECT_CALL(*this, DoStartRendering()); | 662 EXPECT_CALL(*this, DoStartRendering()); |
638 EXPECT_CALL(*this, DoReadyStateChanged( | 663 EXPECT_CALL(*this, DoReadyStateChanged( |
639 blink::WebMediaPlayer::ReadyStateHaveMetadata)); | 664 blink::WebMediaPlayer::ReadyStateHaveMetadata)); |
640 EXPECT_CALL(*this, DoReadyStateChanged( | 665 EXPECT_CALL(*this, DoReadyStateChanged( |
641 blink::WebMediaPlayer::ReadyStateHaveEnoughData)); | 666 blink::WebMediaPlayer::ReadyStateHaveEnoughData)); |
| 667 gfx::Size frame_size = |
| 668 gfx::Size(kStandardWidth - (odd_size_frame ? kOddSizeOffset : 0), |
| 669 kStandardHeight - (odd_size_frame ? kOddSizeOffset : 0)); |
| 670 EXPECT_CALL(*this, CheckSizeChanged(frame_size)); |
642 message_loop_controller_.RunAndWaitForStatus( | 671 message_loop_controller_.RunAndWaitForStatus( |
643 media::PipelineStatus::PIPELINE_OK); | 672 media::PipelineStatus::PIPELINE_OK); |
644 testing::Mock::VerifyAndClearExpectations(this); | 673 testing::Mock::VerifyAndClearExpectations(this); |
645 | 674 |
646 // Here we call pause, and expect a freezing frame. | 675 // Here we call pause, and expect a freezing frame. |
647 EXPECT_CALL(*this, DoStopRendering()); | 676 EXPECT_CALL(*this, DoStopRendering()); |
648 player_.pause(); | 677 player_.pause(); |
649 auto prev_frame = compositor_->GetCurrentFrame(); | 678 auto prev_frame = compositor_->GetCurrentFrame(); |
650 message_loop_controller_.RunAndWaitForStatus( | 679 message_loop_controller_.RunAndWaitForStatus( |
651 media::PipelineStatus::PIPELINE_OK); | 680 media::PipelineStatus::PIPELINE_OK); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 433, kTestBrake, 466, 500, 533, 566, 600}; | 716 433, kTestBrake, 466, 500, 533, 566, 600}; |
688 std::vector<int> timestamps(tokens, tokens + sizeof(tokens) / sizeof(int)); | 717 std::vector<int> timestamps(tokens, tokens + sizeof(tokens) / sizeof(int)); |
689 provider->QueueFrames(timestamps); | 718 provider->QueueFrames(timestamps); |
690 | 719 |
691 EXPECT_CALL(*this, DoSetWebLayer(true)); | 720 EXPECT_CALL(*this, DoSetWebLayer(true)); |
692 EXPECT_CALL(*this, DoStartRendering()); | 721 EXPECT_CALL(*this, DoStartRendering()); |
693 EXPECT_CALL(*this, DoReadyStateChanged( | 722 EXPECT_CALL(*this, DoReadyStateChanged( |
694 blink::WebMediaPlayer::ReadyStateHaveMetadata)); | 723 blink::WebMediaPlayer::ReadyStateHaveMetadata)); |
695 EXPECT_CALL(*this, DoReadyStateChanged( | 724 EXPECT_CALL(*this, DoReadyStateChanged( |
696 blink::WebMediaPlayer::ReadyStateHaveEnoughData)); | 725 blink::WebMediaPlayer::ReadyStateHaveEnoughData)); |
697 | 726 gfx::Size frame_size = gfx::Size(kStandardWidth, kStandardHeight); |
| 727 EXPECT_CALL(*this, CheckSizeChanged(frame_size)); |
698 message_loop_controller_.RunAndWaitForStatus( | 728 message_loop_controller_.RunAndWaitForStatus( |
699 media::PipelineStatus::PIPELINE_OK); | 729 media::PipelineStatus::PIPELINE_OK); |
700 testing::Mock::VerifyAndClearExpectations(this); | 730 testing::Mock::VerifyAndClearExpectations(this); |
701 | 731 |
702 // Switch to background rendering, expect rendering to continue. | 732 // Switch to background rendering, expect rendering to continue. |
703 SetBackgroundRendering(true); | 733 SetBackgroundRendering(true); |
704 auto prev_frame = compositor_->GetCurrentFrame(); | 734 auto prev_frame = compositor_->GetCurrentFrame(); |
705 message_loop_controller_.RunAndWaitForStatus( | 735 message_loop_controller_.RunAndWaitForStatus( |
706 media::PipelineStatus::PIPELINE_OK); | 736 media::PipelineStatus::PIPELINE_OK); |
707 auto after_frame = compositor_->GetCurrentFrame(); | 737 auto after_frame = compositor_->GetCurrentFrame(); |
708 EXPECT_NE(prev_frame->timestamp(), after_frame->timestamp()); | 738 EXPECT_NE(prev_frame->timestamp(), after_frame->timestamp()); |
709 | 739 |
710 // Switch to foreground rendering. | 740 // Switch to foreground rendering. |
711 SetBackgroundRendering(false); | 741 SetBackgroundRendering(false); |
712 prev_frame = compositor_->GetCurrentFrame(); | 742 prev_frame = compositor_->GetCurrentFrame(); |
713 message_loop_controller_.RunAndWaitForStatus( | 743 message_loop_controller_.RunAndWaitForStatus( |
714 media::PipelineStatus::PIPELINE_OK); | 744 media::PipelineStatus::PIPELINE_OK); |
715 after_frame = compositor_->GetCurrentFrame(); | 745 after_frame = compositor_->GetCurrentFrame(); |
716 EXPECT_NE(prev_frame->timestamp(), after_frame->timestamp()); | 746 EXPECT_NE(prev_frame->timestamp(), after_frame->timestamp()); |
717 testing::Mock::VerifyAndClearExpectations(this); | 747 testing::Mock::VerifyAndClearExpectations(this); |
718 | 748 |
719 EXPECT_CALL(*this, DoSetWebLayer(false)); | 749 EXPECT_CALL(*this, DoSetWebLayer(false)); |
720 EXPECT_CALL(*this, DoStopRendering()); | 750 EXPECT_CALL(*this, DoStopRendering()); |
721 } | 751 } |
722 | 752 |
| 753 TEST_F(WebMediaPlayerMSTest, FrameSizeChange) { |
| 754 // During this test, the frame size of the input changes. |
| 755 // We need to make sure, when sizeChanged() gets called, new size should be |
| 756 // returned by GetCurrentSize(). |
| 757 MockVideoFrameProvider* provider = LoadAndGetFrameProvider(true); |
| 758 |
| 759 int tokens[] = {0, 33, 66, 100, 133, 166, 200, 233, 266, 300, |
| 760 333, 366, 400, 433, 466, 500, 533, 566, 600}; |
| 761 std::vector<int> timestamps(tokens, tokens + sizeof(tokens) / sizeof(int)); |
| 762 provider->QueueFrames(timestamps, false, false, 7); |
| 763 |
| 764 EXPECT_CALL(*this, DoSetWebLayer(true)); |
| 765 EXPECT_CALL(*this, DoStartRendering()); |
| 766 EXPECT_CALL(*this, DoReadyStateChanged( |
| 767 blink::WebMediaPlayer::ReadyStateHaveMetadata)); |
| 768 EXPECT_CALL(*this, DoReadyStateChanged( |
| 769 blink::WebMediaPlayer::ReadyStateHaveEnoughData)); |
| 770 EXPECT_CALL(*this, |
| 771 CheckSizeChanged(gfx::Size(kStandardWidth, kStandardHeight))); |
| 772 EXPECT_CALL(*this, CheckSizeChanged( |
| 773 gfx::Size(kStandardWidth * 2, kStandardHeight * 2))); |
| 774 message_loop_controller_.RunAndWaitForStatus( |
| 775 media::PipelineStatus::PIPELINE_OK); |
| 776 testing::Mock::VerifyAndClearExpectations(this); |
| 777 |
| 778 EXPECT_CALL(*this, DoSetWebLayer(false)); |
| 779 EXPECT_CALL(*this, DoStopRendering()); |
| 780 } |
| 781 |
723 #if defined(OS_ANDROID) | 782 #if defined(OS_ANDROID) |
724 TEST_F(WebMediaPlayerMSTest, HiddenPlayerTests) { | 783 TEST_F(WebMediaPlayerMSTest, HiddenPlayerTests) { |
725 LoadAndGetFrameProvider(true); | 784 LoadAndGetFrameProvider(true); |
726 | 785 |
727 // Hidden status should not affect playback. | 786 // Hidden status should not affect playback. |
728 delegate_.set_hidden(true); | 787 delegate_.set_hidden(true); |
729 player_.play(); | 788 player_.play(); |
730 EXPECT_FALSE(player_.paused()); | 789 EXPECT_FALSE(player_.paused()); |
731 | 790 |
732 // A pause delivered via the delegate should not pause the video since these | 791 // A pause delivered via the delegate should not pause the video since these |
(...skipping 30 matching lines...) Expand all Loading... |
763 EXPECT_TRUE(player_.paused()); | 822 EXPECT_TRUE(player_.paused()); |
764 | 823 |
765 // OnShown() should restart after a forced suspension. | 824 // OnShown() should restart after a forced suspension. |
766 player_.OnShown(); | 825 player_.OnShown(); |
767 EXPECT_FALSE(player_.paused()); | 826 EXPECT_FALSE(player_.paused()); |
768 EXPECT_CALL(*this, DoSetWebLayer(false)); | 827 EXPECT_CALL(*this, DoSetWebLayer(false)); |
769 } | 828 } |
770 #endif | 829 #endif |
771 | 830 |
772 } // namespace content | 831 } // namespace content |
OLD | NEW |