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

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: merged, comment updated Created 6 years, 3 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.get(), 406 PopulateVideoFrame(expected_I420_frame.get(),
407 expected_video_frame.start_value); 407 expected_video_frame.start_value);
408 408
409 EXPECT_GE(I420PSNR(expected_I420_frame, video_frame), kVideoAcceptedPSNR); 409 if (expected_video_frame.should_be_continuous) {
410 EXPECT_GE(I420PSNR(expected_I420_frame, video_frame), kVideoAcceptedPSNR);
411 }
410 412
411 EXPECT_NEAR( 413 EXPECT_NEAR(
412 (playout_time - expected_video_frame.playout_time).InMillisecondsF(), 414 (playout_time - expected_video_frame.playout_time).InMillisecondsF(),
413 0.0, 415 0.0,
414 kMaxAllowedPlayoutErrorMs); 416 kMaxAllowedPlayoutErrorMs);
415 VLOG_IF(1, !last_playout_time_.is_null()) 417 VLOG_IF(1, !last_playout_time_.is_null())
416 << "Video frame playout time delta (compared to last frame) is " 418 << "Video frame playout time delta (compared to last frame) is "
417 << (playout_time - last_playout_time_).InMicroseconds() << " usec."; 419 << (playout_time - last_playout_time_).InMicroseconds() << " usec.";
418 last_playout_time_ = playout_time; 420 last_playout_time_ = playout_time;
419 421
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 RunTasks(kFrameTimerMs - kAudioFrameDurationMs); 983 RunTasks(kFrameTimerMs - kAudioFrameDurationMs);
982 audio_diff += kFrameTimerMs; 984 audio_diff += kFrameTimerMs;
983 video_start++; 985 video_start++;
984 } 986 }
985 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. 987 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline.
986 EXPECT_EQ(num_audio_frames_requested, 988 EXPECT_EQ(num_audio_frames_requested,
987 test_receiver_audio_callback_->number_times_called()); 989 test_receiver_audio_callback_->number_times_called());
988 EXPECT_EQ(10, test_receiver_video_callback_->number_times_called()); 990 EXPECT_EQ(10, test_receiver_video_callback_->number_times_called());
989 } 991 }
990 992
991 // This tests a network glitch lasting for 10 video frames. 993 TEST_F(End2EndTest, DropEveryOtherFrame3Buffers) {
992 // Flaky. See crbug.com/351596. 994 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_OPUS, kDefaultAudioSamplingRate, 3);
993 TEST_F(End2EndTest, DISABLED_GlitchWith3Buffers) { 995 int target_delay = 300;
994 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_OPUS,
995 kDefaultAudioSamplingRate, 3);
996 video_sender_config_.target_playout_delay = 996 video_sender_config_.target_playout_delay =
997 base::TimeDelta::FromMilliseconds(67); 997 base::TimeDelta::FromMilliseconds(target_delay);
998 video_receiver_config_.rtp_max_delay_ms = 67; 998 video_receiver_config_.rtp_max_delay_ms = target_delay;
999 Create();
1000
1001 int video_start = kVideoStart;
1002 base::TimeTicks capture_time;
1003 // Frames will rendered on completion until the render time stabilizes, i.e.
1004 // we got enough data.
1005 const int frames_before_glitch = 20;
1006 for (int i = 0; i < frames_before_glitch; ++i) {
1007 capture_time = testing_clock_sender_->NowTicks();
1008 SendVideoFrame(video_start, capture_time);
1009 test_receiver_video_callback_->AddExpectedResult(
1010 video_start,
1011 video_sender_config_.width,
1012 video_sender_config_.height,
1013 capture_time + base::TimeDelta::FromMilliseconds(kTargetPlayoutDelayMs),
1014 true);
1015 cast_receiver_->RequestDecodedVideoFrame(
1016 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame,
1017 test_receiver_video_callback_));
1018 RunTasks(kFrameTimerMs);
1019 video_start++;
1020 }
1021
1022 // Introduce a glitch lasting for 10 frames.
1023 sender_to_receiver_.SetSendPackets(false);
1024 for (int i = 0; i < 10; ++i) {
1025 capture_time = testing_clock_sender_->NowTicks();
1026 // First 3 will be sent and lost.
1027 SendVideoFrame(video_start, capture_time);
1028 RunTasks(kFrameTimerMs);
1029 video_start++;
1030 }
1031 sender_to_receiver_.SetSendPackets(true);
1032 RunTasks(100);
1033 capture_time = testing_clock_sender_->NowTicks();
1034
1035 // Frame 1 should be acked by now and we should have an opening to send 4.
1036 SendVideoFrame(video_start, capture_time);
1037 RunTasks(kFrameTimerMs);
1038
1039 // Frames 1-3 are old frames by now, and therefore should be decoded, but
1040 // not rendered. The next frame we expect to render is frame #4.
1041 test_receiver_video_callback_->AddExpectedResult(
1042 video_start,
1043 video_sender_config_.width,
1044 video_sender_config_.height,
1045 capture_time + base::TimeDelta::FromMilliseconds(kTargetPlayoutDelayMs),
1046 true);
1047
1048 cast_receiver_->RequestDecodedVideoFrame(
1049 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame,
1050 test_receiver_video_callback_));
1051
1052 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline.
1053 EXPECT_EQ(frames_before_glitch + 1,
1054 test_receiver_video_callback_->number_times_called());
1055 }
1056
1057 // Disabled due to flakiness and crashiness. http://crbug.com/360951
1058 TEST_F(End2EndTest, DISABLED_DropEveryOtherFrame3Buffers) {
1059 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_OPUS,
1060 kDefaultAudioSamplingRate, 3);
1061 video_sender_config_.target_playout_delay =
1062 base::TimeDelta::FromMilliseconds(67);
1063 video_receiver_config_.rtp_max_delay_ms = 67;
1064 Create(); 999 Create();
1065 sender_to_receiver_.DropAllPacketsBelongingToOddFrames(); 1000 sender_to_receiver_.DropAllPacketsBelongingToOddFrames();
1066 1001
1067 int video_start = kVideoStart; 1002 int video_start = kVideoStart;
1068 base::TimeTicks capture_time; 1003 base::TimeTicks capture_time;
1069 1004
1070 int i = 0; 1005 int i = 0;
1071 for (; i < 20; ++i) { 1006 for (; i < 20; ++i) {
1072 capture_time = testing_clock_sender_->NowTicks(); 1007 capture_time = testing_clock_sender_->NowTicks();
1073 SendVideoFrame(video_start, capture_time); 1008 SendVideoFrame(video_start, capture_time);
1074 1009
1075 if (i % 2 == 0) { 1010 if (i % 2 == 0) {
1076 test_receiver_video_callback_->AddExpectedResult( 1011 test_receiver_video_callback_->AddExpectedResult(
1077 video_start, 1012 video_start,
1078 video_sender_config_.width, 1013 video_sender_config_.width,
1079 video_sender_config_.height, 1014 video_sender_config_.height,
1080 capture_time + 1015 capture_time +
1081 base::TimeDelta::FromMilliseconds(kTargetPlayoutDelayMs), 1016 base::TimeDelta::FromMilliseconds(target_delay),
1082 i == 0); 1017 i == 0);
1083 1018
1084 // GetRawVideoFrame will not return the frame until we are close in 1019 // GetRawVideoFrame will not return the frame until we are close in
1085 // time before we should render the frame. 1020 // time before we should render the frame.
1086 cast_receiver_->RequestDecodedVideoFrame( 1021 cast_receiver_->RequestDecodedVideoFrame(
1087 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame, 1022 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame,
1088 test_receiver_video_callback_)); 1023 test_receiver_video_callback_));
1089 } 1024 }
1090 RunTasks(kFrameTimerMs); 1025 RunTasks(kFrameTimerMs);
1091 video_start++; 1026 video_start++;
1092 } 1027 }
1093 1028
1094 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. 1029 RunTasks(2 * kFrameTimerMs + target_delay); // Empty the pipeline.
1095 EXPECT_EQ(i / 2, test_receiver_video_callback_->number_times_called()); 1030 EXPECT_EQ(i / 2, test_receiver_video_callback_->number_times_called());
1096 } 1031 }
1097 1032
1098 TEST_F(End2EndTest, CryptoVideo) { 1033 TEST_F(End2EndTest, CryptoVideo) {
1099 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_PCM16, 32000, 1); 1034 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_PCM16, 32000, 1);
1100 1035
1101 video_sender_config_.aes_iv_mask = 1036 video_sender_config_.aes_iv_mask =
1102 ConvertFromBase16String("1234567890abcdeffedcba0987654321"); 1037 ConvertFromBase16String("1234567890abcdeffedcba0987654321");
1103 video_sender_config_.aes_key = 1038 video_sender_config_.aes_key =
1104 ConvertFromBase16String("deadbeefcafeb0b0b0b0cafedeadbeef"); 1039 ConvertFromBase16String("deadbeefcafeb0b0b0b0cafedeadbeef");
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 EXPECT_LT(jump, 220u); 1462 EXPECT_LT(jump, 220u);
1528 } 1463 }
1529 1464
1530 // TODO(pwestin): Add repeatable packet loss test. 1465 // TODO(pwestin): Add repeatable packet loss test.
1531 // TODO(pwestin): Add test for misaligned send get calls. 1466 // TODO(pwestin): Add test for misaligned send get calls.
1532 // TODO(pwestin): Add more tests that does not resample. 1467 // TODO(pwestin): Add more tests that does not resample.
1533 // TODO(pwestin): Add test when we have starvation for our RunTask. 1468 // TODO(pwestin): Add test when we have starvation for our RunTask.
1534 1469
1535 } // namespace cast 1470 } // namespace cast
1536 } // namespace media 1471 } // 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