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 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 } | 887 } |
888 | 888 |
889 // This tests a network glitch lasting for 10 video frames. | 889 // This tests a network glitch lasting for 10 video frames. |
890 TEST_F(End2EndTest, GlitchWith3Buffers) { | 890 TEST_F(End2EndTest, GlitchWith3Buffers) { |
891 SetupConfig(transport::kOpus, kDefaultAudioSamplingRate, false, 3); | 891 SetupConfig(transport::kOpus, kDefaultAudioSamplingRate, false, 3); |
892 video_sender_config_.rtp_config.max_delay_ms = 67; | 892 video_sender_config_.rtp_config.max_delay_ms = 67; |
893 video_receiver_config_.rtp_max_delay_ms = 67; | 893 video_receiver_config_.rtp_max_delay_ms = 67; |
894 Create(); | 894 Create(); |
895 | 895 |
896 int video_start = kVideoStart; | 896 int video_start = kVideoStart; |
897 base::TimeTicks send_time = testing_clock_sender_->NowTicks(); | 897 base::TimeTicks send_time; |
898 SendVideoFrame(video_start, send_time); | 898 // Frames will rendered on completion until the render time stabilizes, i.e. |
899 RunTasks(kFrameTimerMs); | 899 // we got enough data. |
900 | 900 const int frames_before_glitch = 20; |
901 test_receiver_video_callback_->AddExpectedResult(video_start, | 901 for (int i = 0; i < frames_before_glitch; ++i) { |
902 video_sender_config_.width, | 902 send_time = testing_clock_sender_->NowTicks(); |
903 video_sender_config_.height, | 903 SendVideoFrame(video_start, send_time); |
904 send_time); | 904 test_receiver_video_callback_->AddExpectedResult( |
905 frame_receiver_->GetRawVideoFrame( | 905 video_start, |
906 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame, | 906 video_sender_config_.width, |
907 test_receiver_video_callback_)); | 907 video_sender_config_.height, |
908 | 908 send_time); |
909 RunTasks(750); // Make sure that we send a RTCP packet. | 909 frame_receiver_->GetRawVideoFrame( |
910 | 910 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame, |
911 video_start++; | 911 test_receiver_video_callback_)); |
| 912 RunTasks(kFrameTimerMs); |
| 913 video_start++; |
| 914 } |
912 | 915 |
913 // Introduce a glitch lasting for 10 frames. | 916 // Introduce a glitch lasting for 10 frames. |
914 sender_to_receiver_.SetSendPackets(false); | 917 sender_to_receiver_.SetSendPackets(false); |
915 for (int i = 0; i < 10; ++i) { | 918 for (int i = 0; i < 10; ++i) { |
916 send_time = testing_clock_sender_->NowTicks(); | 919 send_time = testing_clock_sender_->NowTicks(); |
917 // First 3 will be sent and lost. | 920 // First 3 will be sent and lost. |
918 SendVideoFrame(video_start, send_time); | 921 SendVideoFrame(video_start, send_time); |
919 RunTasks(kFrameTimerMs); | 922 RunTasks(kFrameTimerMs); |
920 video_start++; | 923 video_start++; |
921 } | 924 } |
(...skipping 10 matching lines...) Expand all Loading... |
932 test_receiver_video_callback_->AddExpectedResult(video_start, | 935 test_receiver_video_callback_->AddExpectedResult(video_start, |
933 video_sender_config_.width, | 936 video_sender_config_.width, |
934 video_sender_config_.height, | 937 video_sender_config_.height, |
935 send_time); | 938 send_time); |
936 | 939 |
937 frame_receiver_->GetRawVideoFrame( | 940 frame_receiver_->GetRawVideoFrame( |
938 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame, | 941 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame, |
939 test_receiver_video_callback_)); | 942 test_receiver_video_callback_)); |
940 | 943 |
941 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. | 944 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. |
942 EXPECT_EQ(2, test_receiver_video_callback_->number_times_called()); | 945 EXPECT_EQ(frames_before_glitch + 1, |
| 946 test_receiver_video_callback_->number_times_called()); |
943 } | 947 } |
944 | 948 |
945 TEST_F(End2EndTest, DropEveryOtherFrame3Buffers) { | 949 TEST_F(End2EndTest, DropEveryOtherFrame3Buffers) { |
946 SetupConfig(transport::kOpus, kDefaultAudioSamplingRate, false, 3); | 950 SetupConfig(transport::kOpus, kDefaultAudioSamplingRate, false, 3); |
947 video_sender_config_.rtp_config.max_delay_ms = 67; | 951 video_sender_config_.rtp_config.max_delay_ms = 67; |
948 video_receiver_config_.rtp_max_delay_ms = 67; | 952 video_receiver_config_.rtp_max_delay_ms = 67; |
949 Create(); | 953 Create(); |
950 sender_to_receiver_.DropAllPacketsBelongingToOddFrames(); | 954 sender_to_receiver_.DropAllPacketsBelongingToOddFrames(); |
951 | 955 |
952 int video_start = kVideoStart; | 956 int video_start = kVideoStart; |
(...skipping 26 matching lines...) Expand all Loading... |
979 } | 983 } |
980 | 984 |
981 TEST_F(End2EndTest, ResetReferenceFrameId) { | 985 TEST_F(End2EndTest, ResetReferenceFrameId) { |
982 SetupConfig(transport::kOpus, kDefaultAudioSamplingRate, false, 3); | 986 SetupConfig(transport::kOpus, kDefaultAudioSamplingRate, false, 3); |
983 video_sender_config_.rtp_config.max_delay_ms = 67; | 987 video_sender_config_.rtp_config.max_delay_ms = 67; |
984 video_receiver_config_.rtp_max_delay_ms = 67; | 988 video_receiver_config_.rtp_max_delay_ms = 67; |
985 Create(); | 989 Create(); |
986 sender_to_receiver_.AlwaysResetReferenceFrameId(); | 990 sender_to_receiver_.AlwaysResetReferenceFrameId(); |
987 | 991 |
988 int frames_counter = 0; | 992 int frames_counter = 0; |
989 for (; frames_counter < 20; ++frames_counter) { | 993 for (; frames_counter < 10; ++frames_counter) { |
990 const base::TimeTicks send_time = testing_clock_sender_->NowTicks(); | 994 const base::TimeTicks send_time = testing_clock_sender_->NowTicks(); |
991 SendVideoFrame(frames_counter, send_time); | 995 SendVideoFrame(frames_counter, send_time); |
992 | 996 |
993 test_receiver_video_callback_->AddExpectedResult( | 997 test_receiver_video_callback_->AddExpectedResult( |
994 frames_counter, | 998 frames_counter, |
995 video_sender_config_.width, | 999 video_sender_config_.width, |
996 video_sender_config_.height, | 1000 video_sender_config_.height, |
997 send_time); | 1001 send_time); |
998 | 1002 |
999 // GetRawVideoFrame will not return the frame until we are close to the | 1003 // GetRawVideoFrame will not return the frame until we are close to the |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); | 1355 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); |
1352 } | 1356 } |
1353 | 1357 |
1354 // TODO(pwestin): Add repeatable packet loss test. | 1358 // TODO(pwestin): Add repeatable packet loss test. |
1355 // TODO(pwestin): Add test for misaligned send get calls. | 1359 // TODO(pwestin): Add test for misaligned send get calls. |
1356 // TODO(pwestin): Add more tests that does not resample. | 1360 // TODO(pwestin): Add more tests that does not resample. |
1357 // TODO(pwestin): Add test when we have starvation for our RunTask. | 1361 // TODO(pwestin): Add test when we have starvation for our RunTask. |
1358 | 1362 |
1359 } // namespace cast | 1363 } // namespace cast |
1360 } // namespace media | 1364 } // namespace media |
OLD | NEW |