| OLD | NEW |
| 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 // This test generate synthetic data. For audio it's a sinusoid waveform with | 5 // This test generate synthetic data. For audio it's a sinusoid waveform with |
| 6 // frequency kSoundFrequency and different amplitudes. For video it's a pattern | 6 // frequency kSoundFrequency and different amplitudes. For video it's a pattern |
| 7 // that is shifting by one pixel per frame, each pixels neighbors right and down | 7 // that is shifting by one pixel per frame, each pixels neighbors right and down |
| 8 // is this pixels value +1, since the pixel value is 8 bit it will wrap | 8 // is this pixels value +1, since the pixel value is 8 bit it will wrap |
| 9 // frequently within the image. Visually this will create diagonally color bands | 9 // frequently within the image. Visually this will create diagonally color bands |
| 10 // that moves across the screen | 10 // that moves across the screen |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 expected_video_frame.playout_time = playout_time; | 383 expected_video_frame.playout_time = playout_time; |
| 384 expected_video_frame.should_be_continuous = should_be_continuous; | 384 expected_video_frame.should_be_continuous = should_be_continuous; |
| 385 expected_frame_.push_back(expected_video_frame); | 385 expected_frame_.push_back(expected_video_frame); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void CheckVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, | 388 void CheckVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, |
| 389 const base::TimeTicks& playout_time, | 389 const base::TimeTicks& playout_time, |
| 390 bool is_continuous) { | 390 bool is_continuous) { |
| 391 ++num_called_; | 391 ++num_called_; |
| 392 | 392 |
| 393 ASSERT_TRUE(!!video_frame); | 393 ASSERT_TRUE(!!video_frame.get()); |
| 394 ASSERT_FALSE(expected_frame_.empty()); | 394 ASSERT_FALSE(expected_frame_.empty()); |
| 395 ExpectedVideoFrame expected_video_frame = expected_frame_.front(); | 395 ExpectedVideoFrame expected_video_frame = expected_frame_.front(); |
| 396 expected_frame_.pop_front(); | 396 expected_frame_.pop_front(); |
| 397 | 397 |
| 398 EXPECT_EQ(expected_video_frame.width, video_frame->visible_rect().width()); | 398 EXPECT_EQ(expected_video_frame.width, video_frame->visible_rect().width()); |
| 399 EXPECT_EQ(expected_video_frame.height, | 399 EXPECT_EQ(expected_video_frame.height, |
| 400 video_frame->visible_rect().height()); | 400 video_frame->visible_rect().height()); |
| 401 | 401 |
| 402 gfx::Size size(expected_video_frame.width, expected_video_frame.height); | 402 gfx::Size size(expected_video_frame.width, expected_video_frame.height); |
| 403 scoped_refptr<media::VideoFrame> expected_I420_frame = | 403 scoped_refptr<media::VideoFrame> expected_I420_frame = |
| 404 media::VideoFrame::CreateFrame( | 404 media::VideoFrame::CreateFrame( |
| 405 VideoFrame::I420, size, gfx::Rect(size), size, base::TimeDelta()); | 405 VideoFrame::I420, size, gfx::Rect(size), size, base::TimeDelta()); |
| 406 PopulateVideoFrame(expected_I420_frame, expected_video_frame.start_value); | 406 PopulateVideoFrame(expected_I420_frame.get(), |
| 407 expected_video_frame.start_value); |
| 407 | 408 |
| 408 EXPECT_GE(I420PSNR(expected_I420_frame, video_frame), kVideoAcceptedPSNR); | 409 EXPECT_GE(I420PSNR(expected_I420_frame, video_frame), kVideoAcceptedPSNR); |
| 409 | 410 |
| 410 EXPECT_NEAR( | 411 EXPECT_NEAR( |
| 411 (playout_time - expected_video_frame.playout_time).InMillisecondsF(), | 412 (playout_time - expected_video_frame.playout_time).InMillisecondsF(), |
| 412 0.0, | 413 0.0, |
| 413 kMaxAllowedPlayoutErrorMs); | 414 kMaxAllowedPlayoutErrorMs); |
| 414 VLOG_IF(1, !last_playout_time_.is_null()) | 415 VLOG_IF(1, !last_playout_time_.is_null()) |
| 415 << "Video frame playout time delta (compared to last frame) is " | 416 << "Video frame playout time delta (compared to last frame) is " |
| 416 << (playout_time - last_playout_time_).InMicroseconds() << " usec."; | 417 << (playout_time - last_playout_time_).InMicroseconds() << " usec."; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 void SendVideoFrame(int start_value, const base::TimeTicks& capture_time) { | 643 void SendVideoFrame(int start_value, const base::TimeTicks& capture_time) { |
| 643 if (start_time_.is_null()) | 644 if (start_time_.is_null()) |
| 644 start_time_ = capture_time; | 645 start_time_ = capture_time; |
| 645 base::TimeDelta time_diff = capture_time - start_time_; | 646 base::TimeDelta time_diff = capture_time - start_time_; |
| 646 gfx::Size size(video_sender_config_.width, video_sender_config_.height); | 647 gfx::Size size(video_sender_config_.width, video_sender_config_.height); |
| 647 EXPECT_TRUE(VideoFrame::IsValidConfig( | 648 EXPECT_TRUE(VideoFrame::IsValidConfig( |
| 648 VideoFrame::I420, size, gfx::Rect(size), size)); | 649 VideoFrame::I420, size, gfx::Rect(size), size)); |
| 649 scoped_refptr<media::VideoFrame> video_frame = | 650 scoped_refptr<media::VideoFrame> video_frame = |
| 650 media::VideoFrame::CreateFrame( | 651 media::VideoFrame::CreateFrame( |
| 651 VideoFrame::I420, size, gfx::Rect(size), size, time_diff); | 652 VideoFrame::I420, size, gfx::Rect(size), size, time_diff); |
| 652 PopulateVideoFrame(video_frame, start_value); | 653 PopulateVideoFrame(video_frame.get(), start_value); |
| 653 video_frame_input_->InsertRawVideoFrame(video_frame, capture_time); | 654 video_frame_input_->InsertRawVideoFrame(video_frame, capture_time); |
| 654 } | 655 } |
| 655 | 656 |
| 656 void SendFakeVideoFrame(const base::TimeTicks& capture_time) { | 657 void SendFakeVideoFrame(const base::TimeTicks& capture_time) { |
| 657 video_frame_input_->InsertRawVideoFrame( | 658 video_frame_input_->InsertRawVideoFrame( |
| 658 media::VideoFrame::CreateBlackFrame(gfx::Size(2, 2)), capture_time); | 659 media::VideoFrame::CreateBlackFrame(gfx::Size(2, 2)), capture_time); |
| 659 } | 660 } |
| 660 | 661 |
| 661 void RunTasks(int ms) { | 662 void RunTasks(int ms) { |
| 662 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(ms)); | 663 task_runner_->Sleep(base::TimeDelta::FromMilliseconds(ms)); |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 EXPECT_LT(jump, 220u); | 1527 EXPECT_LT(jump, 220u); |
| 1527 } | 1528 } |
| 1528 | 1529 |
| 1529 // TODO(pwestin): Add repeatable packet loss test. | 1530 // TODO(pwestin): Add repeatable packet loss test. |
| 1530 // TODO(pwestin): Add test for misaligned send get calls. | 1531 // TODO(pwestin): Add test for misaligned send get calls. |
| 1531 // TODO(pwestin): Add more tests that does not resample. | 1532 // TODO(pwestin): Add more tests that does not resample. |
| 1532 // TODO(pwestin): Add test when we have starvation for our RunTask. | 1533 // TODO(pwestin): Add test when we have starvation for our RunTask. |
| 1533 | 1534 |
| 1534 } // namespace cast | 1535 } // namespace cast |
| 1535 } // namespace media | 1536 } // namespace media |
| OLD | NEW |