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

Side by Side Diff: media/cast/test/end2end_unittest.cc

Issue 339743002: Cast: Make vp8 3-buffer mode work (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge, fix, cleanup, rince, repeat Created 6 years, 4 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 // 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } else { 203 } else {
204 packet_pipe_ = loopback_pipe.Pass(); 204 packet_pipe_ = loopback_pipe.Pass();
205 } 205 }
206 packet_pipe_->InitOnIOThread(task_runner, clock); 206 packet_pipe_->InitOnIOThread(task_runner, clock);
207 } 207 }
208 208
209 virtual bool SendPacket(PacketRef packet, 209 virtual bool SendPacket(PacketRef packet,
210 const base::Closure& cb) OVERRIDE { 210 const base::Closure& cb) OVERRIDE {
211 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 211 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
212 if (!send_packets_) 212 if (!send_packets_)
213 return false; 213 return true;
214 214
215 bytes_sent_ += packet->data.size(); 215 bytes_sent_ += packet->data.size();
216 if (drop_packets_belonging_to_odd_frames_) { 216 if (drop_packets_belonging_to_odd_frames_) {
217 uint32 frame_id = packet->data[13]; 217 uint32 frame_id = packet->data[13];
218 if (frame_id % 2 == 1) 218 if (frame_id % 2 == 1)
219 return true; 219 return true;
220 } 220 }
221 221
222 scoped_ptr<Packet> packet_copy(new Packet(packet->data)); 222 scoped_ptr<Packet> packet_copy(new Packet(packet->data));
223 packet_pipe_->Send(packet_copy.Pass()); 223 packet_pipe_->Send(packet_copy.Pass());
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, expected_video_frame.start_value);
407 407
408 EXPECT_GE(I420PSNR(expected_I420_frame, video_frame), kVideoAcceptedPSNR); 408 if (expected_video_frame.should_be_continuous) {
409 EXPECT_GE(I420PSNR(expected_I420_frame, video_frame), kVideoAcceptedPSNR);
410 }
409 411
410 EXPECT_NEAR( 412 EXPECT_NEAR(
411 (playout_time - expected_video_frame.playout_time).InMillisecondsF(), 413 (playout_time - expected_video_frame.playout_time).InMillisecondsF(),
412 0.0, 414 0.0,
413 kMaxAllowedPlayoutErrorMs); 415 kMaxAllowedPlayoutErrorMs);
414 VLOG_IF(1, !last_playout_time_.is_null()) 416 VLOG_IF(1, !last_playout_time_.is_null())
415 << "Video frame playout time delta (compared to last frame) is " 417 << "Video frame playout time delta (compared to last frame) is "
416 << (playout_time - last_playout_time_).InMicroseconds() << " usec."; 418 << (playout_time - last_playout_time_).InMicroseconds() << " usec.";
417 last_playout_time_ = playout_time; 419 last_playout_time_ = playout_time;
418 420
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 RunTasks(kFrameTimerMs - kAudioFrameDurationMs); 982 RunTasks(kFrameTimerMs - kAudioFrameDurationMs);
981 audio_diff += kFrameTimerMs; 983 audio_diff += kFrameTimerMs;
982 video_start++; 984 video_start++;
983 } 985 }
984 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. 986 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline.
985 EXPECT_EQ(num_audio_frames_requested, 987 EXPECT_EQ(num_audio_frames_requested,
986 test_receiver_audio_callback_->number_times_called()); 988 test_receiver_audio_callback_->number_times_called());
987 EXPECT_EQ(10, test_receiver_video_callback_->number_times_called()); 989 EXPECT_EQ(10, test_receiver_video_callback_->number_times_called());
988 } 990 }
989 991
990 // This tests a network glitch lasting for 10 video frames. 992 TEST_F(End2EndTest, DropEveryOtherFrame3Buffers) {
991 // Flaky. See crbug.com/351596. 993 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_OPUS, kDefaultAudioSamplingRate, 3);
992 TEST_F(End2EndTest, DISABLED_GlitchWith3Buffers) { 994 int target_delay = 300;
993 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_OPUS,
994 kDefaultAudioSamplingRate, 3);
995 video_sender_config_.target_playout_delay = 995 video_sender_config_.target_playout_delay =
996 base::TimeDelta::FromMilliseconds(67); 996 base::TimeDelta::FromMilliseconds(target_delay);
997 video_receiver_config_.rtp_max_delay_ms = 67; 997 video_receiver_config_.rtp_max_delay_ms = target_delay;
998 Create();
999
1000 int video_start = kVideoStart;
1001 base::TimeTicks capture_time;
1002 // Frames will rendered on completion until the render time stabilizes, i.e.
1003 // we got enough data.
1004 const int frames_before_glitch = 20;
1005 for (int i = 0; i < frames_before_glitch; ++i) {
1006 capture_time = testing_clock_sender_->NowTicks();
1007 SendVideoFrame(video_start, capture_time);
1008 test_receiver_video_callback_->AddExpectedResult(
1009 video_start,
1010 video_sender_config_.width,
1011 video_sender_config_.height,
1012 capture_time + base::TimeDelta::FromMilliseconds(kTargetPlayoutDelayMs),
1013 true);
1014 cast_receiver_->RequestDecodedVideoFrame(
1015 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame,
1016 test_receiver_video_callback_));
1017 RunTasks(kFrameTimerMs);
1018 video_start++;
1019 }
1020
1021 // Introduce a glitch lasting for 10 frames.
1022 sender_to_receiver_.SetSendPackets(false);
1023 for (int i = 0; i < 10; ++i) {
1024 capture_time = testing_clock_sender_->NowTicks();
1025 // First 3 will be sent and lost.
1026 SendVideoFrame(video_start, capture_time);
1027 RunTasks(kFrameTimerMs);
1028 video_start++;
1029 }
1030 sender_to_receiver_.SetSendPackets(true);
1031 RunTasks(100);
1032 capture_time = testing_clock_sender_->NowTicks();
1033
1034 // Frame 1 should be acked by now and we should have an opening to send 4.
1035 SendVideoFrame(video_start, capture_time);
1036 RunTasks(kFrameTimerMs);
1037
1038 // Frames 1-3 are old frames by now, and therefore should be decoded, but
1039 // not rendered. The next frame we expect to render is frame #4.
1040 test_receiver_video_callback_->AddExpectedResult(
1041 video_start,
1042 video_sender_config_.width,
1043 video_sender_config_.height,
1044 capture_time + base::TimeDelta::FromMilliseconds(kTargetPlayoutDelayMs),
1045 true);
1046
1047 cast_receiver_->RequestDecodedVideoFrame(
1048 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame,
1049 test_receiver_video_callback_));
1050
1051 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline.
1052 EXPECT_EQ(frames_before_glitch + 1,
1053 test_receiver_video_callback_->number_times_called());
1054 }
1055
1056 // Disabled due to flakiness and crashiness. http://crbug.com/360951
1057 TEST_F(End2EndTest, DISABLED_DropEveryOtherFrame3Buffers) {
1058 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_OPUS,
1059 kDefaultAudioSamplingRate, 3);
1060 video_sender_config_.target_playout_delay =
1061 base::TimeDelta::FromMilliseconds(67);
1062 video_receiver_config_.rtp_max_delay_ms = 67;
1063 Create(); 998 Create();
1064 sender_to_receiver_.DropAllPacketsBelongingToOddFrames(); 999 sender_to_receiver_.DropAllPacketsBelongingToOddFrames();
1065 1000
1066 int video_start = kVideoStart; 1001 int video_start = kVideoStart;
1067 base::TimeTicks capture_time; 1002 base::TimeTicks capture_time;
1068 1003
1069 int i = 0; 1004 int i = 0;
1070 for (; i < 20; ++i) { 1005 for (; i < 20; ++i) {
1071 capture_time = testing_clock_sender_->NowTicks(); 1006 capture_time = testing_clock_sender_->NowTicks();
1072 SendVideoFrame(video_start, capture_time); 1007 SendVideoFrame(video_start, capture_time);
1073 1008
1074 if (i % 2 == 0) { 1009 if (i % 2 == 0) {
1075 test_receiver_video_callback_->AddExpectedResult( 1010 test_receiver_video_callback_->AddExpectedResult(
1076 video_start, 1011 video_start,
1077 video_sender_config_.width, 1012 video_sender_config_.width,
1078 video_sender_config_.height, 1013 video_sender_config_.height,
1079 capture_time + 1014 capture_time +
1080 base::TimeDelta::FromMilliseconds(kTargetPlayoutDelayMs), 1015 base::TimeDelta::FromMilliseconds(target_delay),
1081 i == 0); 1016 i == 0);
1082 1017
1083 // GetRawVideoFrame will not return the frame until we are close in 1018 // GetRawVideoFrame will not return the frame until we are close in
1084 // time before we should render the frame. 1019 // time before we should render the frame.
1085 cast_receiver_->RequestDecodedVideoFrame( 1020 cast_receiver_->RequestDecodedVideoFrame(
1086 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame, 1021 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame,
1087 test_receiver_video_callback_)); 1022 test_receiver_video_callback_));
1088 } 1023 }
1089 RunTasks(kFrameTimerMs); 1024 RunTasks(kFrameTimerMs);
1090 video_start++; 1025 video_start++;
1091 } 1026 }
1092 1027
1093 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. 1028 RunTasks(2 * kFrameTimerMs + target_delay); // Empty the pipeline.
1094 EXPECT_EQ(i / 2, test_receiver_video_callback_->number_times_called()); 1029 EXPECT_EQ(i / 2, test_receiver_video_callback_->number_times_called());
1095 } 1030 }
1096 1031
1097 TEST_F(End2EndTest, CryptoVideo) { 1032 TEST_F(End2EndTest, CryptoVideo) {
1098 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_PCM16, 32000, 1); 1033 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_PCM16, 32000, 1);
1099 1034
1100 video_sender_config_.aes_iv_mask = 1035 video_sender_config_.aes_iv_mask =
1101 ConvertFromBase16String("1234567890abcdeffedcba0987654321"); 1036 ConvertFromBase16String("1234567890abcdeffedcba0987654321");
1102 video_sender_config_.aes_key = 1037 video_sender_config_.aes_key =
1103 ConvertFromBase16String("deadbeefcafeb0b0b0b0cafedeadbeef"); 1038 ConvertFromBase16String("deadbeefcafeb0b0b0b0cafedeadbeef");
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 EXPECT_EQ(10000ul, video_ticks_.size()); 1429 EXPECT_EQ(10000ul, video_ticks_.size());
1495 } 1430 }
1496 1431
1497 // TODO(pwestin): Add repeatable packet loss test. 1432 // TODO(pwestin): Add repeatable packet loss test.
1498 // TODO(pwestin): Add test for misaligned send get calls. 1433 // TODO(pwestin): Add test for misaligned send get calls.
1499 // TODO(pwestin): Add more tests that does not resample. 1434 // TODO(pwestin): Add more tests that does not resample.
1500 // TODO(pwestin): Add test when we have starvation for our RunTask. 1435 // TODO(pwestin): Add test when we have starvation for our RunTask.
1501 1436
1502 } // namespace cast 1437 } // namespace cast
1503 } // namespace media 1438 } // namespace media
OLDNEW
« media/cast/sender/vp8_encoder.cc ('K') | « media/cast/sender/vp8_encoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698