Chromium Code Reviews| 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 protected: | 315 protected: |
| 316 virtual ~TestReceiverVideoCallback() {} | 316 virtual ~TestReceiverVideoCallback() {} |
| 317 | 317 |
| 318 private: | 318 private: |
| 319 friend class base::RefCountedThreadSafe<TestReceiverVideoCallback>; | 319 friend class base::RefCountedThreadSafe<TestReceiverVideoCallback>; |
| 320 | 320 |
| 321 int num_called_; | 321 int num_called_; |
| 322 std::list<ExpectedVideoFrame> expected_frame_; | 322 std::list<ExpectedVideoFrame> expected_frame_; |
| 323 }; | 323 }; |
| 324 | 324 |
| 325 CastLoggingConfig EnableCastLoggingConfig() { | 325 CastLoggingConfig EnableCastLoggingConfig(bool sender) { |
| 326 CastLoggingConfig config; | 326 CastLoggingConfig config(sender); |
| 327 config.enable_data_collection = true; | 327 config.enable_data_collection = true; |
| 328 return config; | 328 return config; |
| 329 } | 329 } |
| 330 // The actual test class, generate synthetic data for both audio and video and | 330 // The actual test class, generate synthetic data for both audio and video and |
| 331 // send those through the sender and receiver and analyzes the result. | 331 // send those through the sender and receiver and analyzes the result. |
| 332 class End2EndTest : public ::testing::Test { | 332 class End2EndTest : public ::testing::Test { |
| 333 protected: | 333 protected: |
| 334 End2EndTest() | 334 End2EndTest() |
| 335 : task_runner_(new test::FakeTaskRunner(&testing_clock_)), | 335 : task_runner_(new test::FakeTaskRunner(&testing_clock_)), |
| 336 cast_environment_(new CastEnvironment(&testing_clock_, task_runner_, | 336 cast_environment_sender_(new CastEnvironment(&testing_clock_, |
| 337 task_runner_, task_runner_, task_runner_, task_runner_, | 337 task_runner_, task_runner_, task_runner_, task_runner_, |
| 338 task_runner_, EnableCastLoggingConfig())), | 338 task_runner_, task_runner_, EnableCastLoggingConfig(true))), |
| 339 cast_environment_receiver_(new CastEnvironment(&testing_clock_, | |
| 340 task_runner_, task_runner_, task_runner_, task_runner_, | |
| 341 task_runner_, task_runner_, EnableCastLoggingConfig(false))), | |
| 339 start_time_(), | 342 start_time_(), |
| 340 sender_to_receiver_(cast_environment_), | 343 sender_to_receiver_(cast_environment_sender_), |
| 341 receiver_to_sender_(cast_environment_), | 344 receiver_to_sender_(cast_environment_receiver_), |
| 342 test_receiver_audio_callback_(new TestReceiverAudioCallback()), | 345 test_receiver_audio_callback_(new TestReceiverAudioCallback()), |
| 343 test_receiver_video_callback_(new TestReceiverVideoCallback()) { | 346 test_receiver_video_callback_(new TestReceiverVideoCallback()) { |
| 344 testing_clock_.Advance( | 347 testing_clock_.Advance( |
| 345 base::TimeDelta::FromMilliseconds(kStartMillisecond)); | 348 base::TimeDelta::FromMilliseconds(kStartMillisecond)); |
| 346 } | 349 } |
| 347 | 350 |
| 348 void SetupConfig(transport::AudioCodec audio_codec, | 351 void SetupConfig(transport::AudioCodec audio_codec, |
| 349 int audio_sampling_frequency, | 352 int audio_sampling_frequency, |
| 350 // TODO(miu): 3rd arg is meaningless?!? | 353 // TODO(miu): 3rd arg is meaningless?!? |
| 351 bool external_audio_decoder, | 354 bool external_audio_decoder, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 video_sender_config_.incoming_feedback_ssrc; | 397 video_sender_config_.incoming_feedback_ssrc; |
| 395 video_receiver_config_.incoming_ssrc = | 398 video_receiver_config_.incoming_ssrc = |
| 396 video_sender_config_.sender_ssrc; | 399 video_sender_config_.sender_ssrc; |
| 397 video_receiver_config_.rtp_payload_type = | 400 video_receiver_config_.rtp_payload_type = |
| 398 video_sender_config_.rtp_payload_type; | 401 video_sender_config_.rtp_payload_type; |
| 399 video_receiver_config_.use_external_decoder = false; | 402 video_receiver_config_.use_external_decoder = false; |
| 400 video_receiver_config_.codec = video_sender_config_.codec; | 403 video_receiver_config_.codec = video_sender_config_.codec; |
| 401 } | 404 } |
| 402 | 405 |
| 403 void Create() { | 406 void Create() { |
| 404 cast_receiver_.reset(CastReceiver::CreateCastReceiver(cast_environment_, | 407 cast_receiver_.reset(CastReceiver::CreateCastReceiver( |
| 405 audio_receiver_config_, video_receiver_config_, &receiver_to_sender_)); | 408 cast_environment_receiver_, |
| 409 audio_receiver_config_, | |
| 410 video_receiver_config_, | |
| 411 &receiver_to_sender_)); | |
| 406 | 412 |
| 407 cast_sender_.reset(CastSender::CreateCastSender(cast_environment_, | 413 cast_sender_.reset(CastSender::CreateCastSender(cast_environment_sender_, |
| 408 audio_sender_config_, | 414 audio_sender_config_, |
| 409 video_sender_config_, | 415 video_sender_config_, |
| 410 NULL, | 416 NULL, |
| 411 &sender_to_receiver_)); | 417 &sender_to_receiver_)); |
| 412 | 418 |
| 413 receiver_to_sender_.RegisterPacketReceiver(cast_sender_->packet_receiver()); | 419 receiver_to_sender_.RegisterPacketReceiver(cast_sender_->packet_receiver()); |
| 414 sender_to_receiver_.RegisterPacketReceiver( | 420 sender_to_receiver_.RegisterPacketReceiver( |
| 415 cast_receiver_->packet_receiver()); | 421 cast_receiver_->packet_receiver()); |
| 416 | 422 |
| 417 frame_input_ = cast_sender_->frame_input(); | 423 frame_input_ = cast_sender_->frame_input(); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 447 } | 453 } |
| 448 } | 454 } |
| 449 | 455 |
| 450 AudioReceiverConfig audio_receiver_config_; | 456 AudioReceiverConfig audio_receiver_config_; |
| 451 VideoReceiverConfig video_receiver_config_; | 457 VideoReceiverConfig video_receiver_config_; |
| 452 AudioSenderConfig audio_sender_config_; | 458 AudioSenderConfig audio_sender_config_; |
| 453 VideoSenderConfig video_sender_config_; | 459 VideoSenderConfig video_sender_config_; |
| 454 | 460 |
| 455 base::SimpleTestTickClock testing_clock_; | 461 base::SimpleTestTickClock testing_clock_; |
| 456 scoped_refptr<test::FakeTaskRunner> task_runner_; | 462 scoped_refptr<test::FakeTaskRunner> task_runner_; |
| 457 scoped_refptr<CastEnvironment> cast_environment_; | 463 scoped_refptr<CastEnvironment> cast_environment_sender_; |
| 464 scoped_refptr<CastEnvironment> cast_environment_receiver_; | |
| 458 base::TimeTicks start_time_; | 465 base::TimeTicks start_time_; |
| 459 | 466 |
| 460 LoopBackTransport sender_to_receiver_; | 467 LoopBackTransport sender_to_receiver_; |
| 461 LoopBackTransport receiver_to_sender_; | 468 LoopBackTransport receiver_to_sender_; |
| 462 | 469 |
| 463 scoped_ptr<CastReceiver> cast_receiver_; | 470 scoped_ptr<CastReceiver> cast_receiver_; |
| 464 scoped_ptr<CastSender> cast_sender_; | 471 scoped_ptr<CastSender> cast_sender_; |
| 465 scoped_refptr<FrameInput> frame_input_; | 472 scoped_refptr<FrameInput> frame_input_; |
| 466 scoped_refptr<FrameReceiver> frame_receiver_; | 473 scoped_refptr<FrameReceiver> frame_receiver_; |
| 467 | 474 |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 925 frame_receiver_->GetRawVideoFrame( | 932 frame_receiver_->GetRawVideoFrame( |
| 926 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame, | 933 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame, |
| 927 test_receiver_video_callback_)); | 934 test_receiver_video_callback_)); |
| 928 | 935 |
| 929 video_start++; | 936 video_start++; |
| 930 } | 937 } |
| 931 | 938 |
| 932 // Basic tests. | 939 // Basic tests. |
| 933 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. | 940 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. |
| 934 EXPECT_EQ(i, test_receiver_video_callback_->number_times_called()); | 941 EXPECT_EQ(i, test_receiver_video_callback_->number_times_called()); |
| 935 // Logging tests. | |
| 936 LoggingImpl* logging = cast_environment_->Logging(); | |
| 937 | 942 |
| 938 // Frame logging. | 943 // Sender logging tests. |
| 944 LoggingImpl* sender_log = cast_environment_sender_->Logging(); | |
| 939 | 945 |
| 940 // Verify that all frames and all required events were logged. | 946 // Verify that all frames and all required events were logged. |
| 941 FrameRawMap frame_raw_log = logging->GetFrameRawData(); | 947 FrameRawMap frame_raw_log = sender_log->GetFrameRawData(); |
| 948 | |
| 942 // Every frame should have only one entry. | 949 // Every frame should have only one entry. |
| 943 EXPECT_EQ(static_cast<unsigned int>(i), frame_raw_log.size()); | 950 EXPECT_EQ(static_cast<unsigned int>(i), frame_raw_log.size()); |
| 944 FrameRawMap::const_iterator frame_it = frame_raw_log.begin(); | 951 FrameRawMap::const_iterator frame_it = frame_raw_log.begin(); |
| 952 | |
| 945 // Choose a video frame, and verify that all events were logged. | 953 // Choose a video frame, and verify that all events were logged. |
| 946 std::vector<CastLoggingEvent> event_log = frame_it->second.type; | 954 std::vector<CastLoggingEvent> event_log = frame_it->second.type; |
| 947 EXPECT_TRUE((std::find(event_log.begin(), event_log.end(), | 955 std::vector<CastLoggingEvent>::iterator event_it; |
| 948 kVideoFrameReceived)) != event_log.end()); | 956 event_it = std::find(event_log.begin(), event_log.end(), |
| 949 EXPECT_TRUE((std::find(event_log.begin(), event_log.end(), | 957 kVideoFrameSentToEncoder); |
| 950 kVideoFrameSentToEncoder)) != event_log.end()); | 958 EXPECT_TRUE(event_it != event_log.end()); |
| 951 EXPECT_TRUE((std::find(event_log.begin(), event_log.end(), | 959 event_log.erase(event_it); |
| 952 kVideoFrameEncoded)) != event_log.end()); | 960 |
| 953 EXPECT_TRUE((std::find(event_log.begin(), event_log.end(), | 961 event_it = std::find(event_log.begin(), event_log.end(), |
| 954 kVideoRenderDelay)) != event_log.end()); | 962 kVideoFrameEncoded); |
| 963 EXPECT_TRUE(event_it != event_log.end()); | |
| 964 event_log.erase(event_it); | |
| 965 | |
| 966 event_it = std::find(event_log.begin(), event_log.end(), | |
| 967 kVideoFrameReceived); | |
| 968 EXPECT_TRUE(event_it != event_log.end()); | |
| 969 event_log.erase(event_it); | |
| 970 | |
| 971 event_it = std::find(event_log.begin(), event_log.end(), | |
| 972 kVideoRenderDelay); | |
| 973 EXPECT_TRUE(event_it != event_log.end()); | |
| 974 event_log.erase(event_it); | |
| 975 | |
| 955 // TODO(mikhal): Plumb this one through. | 976 // TODO(mikhal): Plumb this one through. |
| 956 EXPECT_TRUE((std::find(event_log.begin(), event_log.end(), | 977 event_it = std::find(event_log.begin(), event_log.end(), |
| 957 kVideoFrameDecoded)) == event_log.end()); | 978 kVideoFrameDecoded); |
| 979 EXPECT_TRUE(event_it == event_log.end()); | |
| 980 | |
| 958 // Verify that there were no other events logged with respect to this frame. | 981 // Verify that there were no other events logged with respect to this frame. |
| 959 EXPECT_EQ(4u, event_log.size()); | 982 EXPECT_EQ(0u, event_log.size()); |
| 960 | 983 |
| 961 // Packet logging. | 984 // Packet logging. |
| 962 // Verify that all packet related events were logged. | 985 // Verify that all packet related events were logged. |
| 963 PacketRawMap packet_raw_log = logging->GetPacketRawData(); | 986 PacketRawMap packet_raw_log = sender_log->GetPacketRawData(); |
| 964 // Every rtp_timestamp should have only one entry. | 987 // Every rtp_timestamp should have only one entry. |
| 965 EXPECT_EQ(static_cast<unsigned int>(i), packet_raw_log.size()); | 988 EXPECT_EQ(static_cast<unsigned int>(i), packet_raw_log.size()); |
| 966 PacketRawMap::const_iterator packet_it = packet_raw_log.begin(); | 989 PacketRawMap::const_iterator packet_it = packet_raw_log.begin(); |
| 967 // Choose a packet, and verify that all events were logged. | 990 // Choose a packet, and verify that all events were logged. |
| 968 event_log = (++(packet_it->second.packet_map.begin()))->second.type; | 991 event_log = (++(packet_it->second.packet_map.begin()))->second.type; |
| 969 EXPECT_TRUE((std::find(event_log.begin(), event_log.end(), | 992 EXPECT_TRUE((std::find(event_log.begin(), event_log.end(), |
| 970 kPacketReceived)) != event_log.end()); | 993 kVideoPacketReceived)) != event_log.end()); |
| 971 // Verify that there were no other events logged with respect to this frame. | 994 // Verify that there were no other events logged with respect to this frame. |
| 972 EXPECT_EQ(1u, event_log.size()); | 995 EXPECT_EQ(1u, event_log.size()); |
| 996 | |
| 997 RunTasks(750); // Make sure that we send a RTCP message with the log. | |
| 998 | |
| 999 // Receiver logging tests. | |
| 1000 LoggingImpl* receiver_log = cast_environment_receiver_->Logging(); | |
| 1001 | |
| 1002 // Verify that all frames and all required events were logged. | |
| 1003 frame_raw_log = receiver_log->GetFrameRawData(); | |
| 1004 EXPECT_EQ(static_cast<unsigned int>(i), frame_raw_log.size()); | |
| 1005 frame_it = frame_raw_log.begin(); | |
| 1006 | |
| 1007 // Choose a video frame, and verify that all events were logged. | |
| 1008 event_log = frame_it->second.type; | |
| 1009 | |
| 1010 event_it = std::find(event_log.begin(), event_log.end(), | |
| 1011 kVideoFrameEncoded); | |
|
mikhal1
2014/01/14 19:57:18
check for not end
pwestin
2014/01/17 23:46:17
Done.
| |
| 1012 | |
| 1013 event_it = std::find(event_log.begin(), event_log.end(), | |
| 1014 kVideoRenderDelay); | |
| 1015 | |
| 1016 EXPECT_TRUE(event_it != event_log.end()); | |
| 1017 EXPECT_EQ(2u, event_log.size()); | |
| 973 } | 1018 } |
| 974 | 1019 |
| 975 // TODO(mikhal): Crashes on the bots. Re-enable. http://crbug.com/329563 | 1020 // TODO(mikhal): Crashes on the bots. Re-enable. http://crbug.com/329563 |
| 976 #if defined(OS_WIN) | 1021 #if defined(OS_WIN) |
| 977 #define MAYBE_AudioLogging DISABLED_AudioLogging | 1022 #define MAYBE_AudioLogging DISABLED_AudioLogging |
| 978 #else | 1023 #else |
| 979 #define MAYBE_AudioLogging AudioLogging | 1024 #define MAYBE_AudioLogging AudioLogging |
| 980 #endif | 1025 #endif |
| 981 // Audio test without packet loss; This test is targeted at testing the logging | 1026 // Audio test without packet loss; This test is targeted at testing the logging |
| 982 // aspects of the end2end, but is basically equivalent to LoopNoLossPcm16. | 1027 // aspects of the end2end, but is basically equivalent to LoopNoLossPcm16. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1022 base::Bind(&TestReceiverAudioCallback::CheckPcmAudioFrame, | 1067 base::Bind(&TestReceiverAudioCallback::CheckPcmAudioFrame, |
| 1023 test_receiver_audio_callback_)); | 1068 test_receiver_audio_callback_)); |
| 1024 } | 1069 } |
| 1025 } | 1070 } |
| 1026 | 1071 |
| 1027 // Basic tests. | 1072 // Basic tests. |
| 1028 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. | 1073 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. |
| 1029 //EXPECT_EQ(i - 1, test_receiver_audio_callback_->number_times_called()); | 1074 //EXPECT_EQ(i - 1, test_receiver_audio_callback_->number_times_called()); |
| 1030 EXPECT_EQ(i - 1, test_receiver_audio_callback_->number_times_called()); | 1075 EXPECT_EQ(i - 1, test_receiver_audio_callback_->number_times_called()); |
| 1031 // Logging tests. | 1076 // Logging tests. |
| 1032 LoggingImpl* logging = cast_environment_->Logging(); | 1077 LoggingImpl* sender_log = cast_environment_sender_->Logging(); |
| 1033 // Verify that all frames and all required events were logged. | 1078 // Verify that all frames and all required events were logged. |
| 1034 FrameRawMap frame_raw_log = logging->GetFrameRawData(); | 1079 FrameRawMap frame_raw_log = sender_log->GetFrameRawData(); |
| 1035 // TODO(mikhal): Results are wrong. Need to resolve passing/calculation of | 1080 // TODO(mikhal): Results are wrong. Need to resolve passing/calculation of |
| 1036 // rtp_timestamp for audio for this to work. | 1081 // rtp_timestamp for audio for this to work. |
| 1037 // Should have logged both audio and video. Every frame should have only one | 1082 // Should have logged both audio and video. Every frame should have only one |
| 1038 // entry. | 1083 // entry. |
| 1039 //EXPECT_EQ(static_cast<unsigned int>(i - 1), frame_raw_log.size()); | 1084 //EXPECT_EQ(static_cast<unsigned int>(i - 1), frame_raw_log.size()); |
| 1040 FrameRawMap::const_iterator frame_it = frame_raw_log.begin(); | 1085 FrameRawMap::const_iterator frame_it = frame_raw_log.begin(); |
| 1041 // Choose a video frame, and verify that all events were logged. | 1086 // Choose a video frame, and verify that all events were logged. |
| 1042 std::vector<CastLoggingEvent> event_log = frame_it->second.type; | 1087 std::vector<CastLoggingEvent> event_log = frame_it->second.type; |
| 1043 EXPECT_TRUE((std::find(event_log.begin(), event_log.end(), | 1088 EXPECT_TRUE((std::find(event_log.begin(), event_log.end(), |
| 1044 kAudioFrameReceived)) != event_log.end()); | 1089 kAudioFrameReceived)) != event_log.end()); |
| 1045 EXPECT_TRUE((std::find(event_log.begin(), event_log.end(), | 1090 EXPECT_TRUE((std::find(event_log.begin(), event_log.end(), |
| 1046 kAudioFrameEncoded)) != event_log.end()); | 1091 kAudioFrameEncoded)) != event_log.end()); |
| 1047 // EXPECT_TRUE((std::find(event_log.begin(), event_log.end(), | 1092 // EXPECT_TRUE((std::find(event_log.begin(), event_log.end(), |
| 1048 // kAudioPlayoutDelay)) != event_log.end()); | 1093 // kAudioPlayoutDelay)) != event_log.end()); |
| 1049 // TODO(mikhal): Plumb this one through. | 1094 // TODO(mikhal): Plumb this one through. |
| 1050 EXPECT_TRUE((std::find(event_log.begin(), event_log.end(), | 1095 EXPECT_TRUE((std::find(event_log.begin(), event_log.end(), |
| 1051 kAudioFrameDecoded)) == event_log.end()); | 1096 kAudioFrameDecoded)) == event_log.end()); |
| 1052 // Verify that there were no other events logged with respect to this frame. | 1097 // Verify that there were no other events logged with respect to this frame. |
| 1053 EXPECT_EQ(2u, event_log.size()); | 1098 EXPECT_EQ(2u, event_log.size()); |
| 1054 } | 1099 } |
| 1055 | 1100 |
| 1056 | 1101 |
| 1057 // TODO(pwestin): Add repeatable packet loss test. | 1102 // TODO(pwestin): Add repeatable packet loss test. |
| 1058 // TODO(pwestin): Add test for misaligned send get calls. | 1103 // TODO(pwestin): Add test for misaligned send get calls. |
| 1059 // TODO(pwestin): Add more tests that does not resample. | 1104 // TODO(pwestin): Add more tests that does not resample. |
| 1060 // TODO(pwestin): Add test when we have starvation for our RunTask. | 1105 // TODO(pwestin): Add test when we have starvation for our RunTask. |
| 1061 | 1106 |
| 1062 } // namespace cast | 1107 } // namespace cast |
| 1063 } // namespace media | 1108 } // namespace media |
| OLD | NEW |