Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 #include <sstream> | 11 #include <sstream> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
| 17 #include "webrtc/base/scoped_ptr.h" | 17 #include "webrtc/base/scoped_ptr.h" |
| 18 #include "webrtc/base/thread_annotations.h" | 18 #include "webrtc/base/thread_annotations.h" |
| 19 #include "webrtc/call.h" | 19 #include "webrtc/call.h" |
| 20 #include "webrtc/call/transport_adapter.h" | 20 #include "webrtc/call/transport_adapter.h" |
| 21 #include "webrtc/config.h" | 21 #include "webrtc/config.h" |
| 22 #include "webrtc/modules/audio_coding/include/audio_coding_module.h" | 22 #include "webrtc/modules/audio_coding/include/audio_coding_module.h" |
| 23 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 23 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
| 24 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 24 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
| 25 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 25 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
| 26 #include "webrtc/system_wrappers/include/rtp_to_ntp.h" | 26 #include "webrtc/system_wrappers/include/rtp_to_ntp.h" |
| 27 #include "webrtc/test/call_test.h" | 27 #include "webrtc/test/call_test.h" |
| 28 #include "webrtc/test/direct_transport.h" | 28 #include "webrtc/test/direct_transport.h" |
| 29 #include "webrtc/test/drifting_clock.h" | |
| 29 #include "webrtc/test/encoder_settings.h" | 30 #include "webrtc/test/encoder_settings.h" |
| 30 #include "webrtc/test/fake_audio_device.h" | 31 #include "webrtc/test/fake_audio_device.h" |
| 31 #include "webrtc/test/fake_decoder.h" | 32 #include "webrtc/test/fake_decoder.h" |
| 32 #include "webrtc/test/fake_encoder.h" | 33 #include "webrtc/test/fake_encoder.h" |
| 33 #include "webrtc/test/frame_generator.h" | 34 #include "webrtc/test/frame_generator.h" |
| 34 #include "webrtc/test/frame_generator_capturer.h" | 35 #include "webrtc/test/frame_generator_capturer.h" |
| 35 #include "webrtc/test/rtp_rtcp_observer.h" | 36 #include "webrtc/test/rtp_rtcp_observer.h" |
| 36 #include "webrtc/test/testsupport/fileutils.h" | 37 #include "webrtc/test/testsupport/fileutils.h" |
| 37 #include "webrtc/test/testsupport/perf_test.h" | 38 #include "webrtc/test/testsupport/perf_test.h" |
| 38 #include "webrtc/voice_engine/include/voe_base.h" | 39 #include "webrtc/voice_engine/include/voe_base.h" |
| 39 #include "webrtc/voice_engine/include/voe_codec.h" | 40 #include "webrtc/voice_engine/include/voe_codec.h" |
| 40 #include "webrtc/voice_engine/include/voe_network.h" | 41 #include "webrtc/voice_engine/include/voe_network.h" |
| 41 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" | 42 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" |
| 42 #include "webrtc/voice_engine/include/voe_video_sync.h" | 43 #include "webrtc/voice_engine/include/voe_video_sync.h" |
| 43 | 44 |
| 44 namespace webrtc { | 45 namespace webrtc { |
| 45 | 46 |
| 46 class CallPerfTest : public test::CallTest { | 47 class CallPerfTest : public test::CallTest { |
| 47 protected: | 48 protected: |
| 48 void TestAudioVideoSync(bool fec, bool create_audio_first); | 49 void TestAudioVideoSync(bool fec, |
| 50 bool create_audio_first, | |
| 51 float audio_rt_drift, | |
| 52 float video_rt_drift, | |
| 53 float video_ntp_drift); | |
| 49 | 54 |
| 50 void TestCpuOveruse(LoadObserver::Load tested_load, int encode_delay_ms); | 55 void TestCpuOveruse(LoadObserver::Load tested_load, int encode_delay_ms); |
| 51 | 56 |
| 52 void TestMinTransmitBitrate(bool pad_to_min_bitrate); | 57 void TestMinTransmitBitrate(bool pad_to_min_bitrate); |
| 53 | 58 |
| 54 void TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, | 59 void TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, |
| 55 int threshold_ms, | 60 int threshold_ms, |
| 56 int start_time_ms, | 61 int start_time_ms, |
| 57 int run_time_ms); | 62 int run_time_ms); |
| 58 }; | 63 }; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 | 186 |
| 182 private: | 187 private: |
| 183 Clock* const clock_; | 188 Clock* const clock_; |
| 184 const int voe_channel_; | 189 const int voe_channel_; |
| 185 VoEVideoSync* const voe_sync_; | 190 VoEVideoSync* const voe_sync_; |
| 186 SyncRtcpObserver* const audio_observer_; | 191 SyncRtcpObserver* const audio_observer_; |
| 187 const int64_t creation_time_ms_; | 192 const int64_t creation_time_ms_; |
| 188 int64_t first_time_in_sync_; | 193 int64_t first_time_in_sync_; |
| 189 }; | 194 }; |
| 190 | 195 |
| 191 void CallPerfTest::TestAudioVideoSync(bool fec, bool create_audio_first) { | 196 void CallPerfTest::TestAudioVideoSync(bool fec, |
| 197 bool create_audio_first, | |
| 198 float audio_rt_drift, | |
| 199 float video_rt_drift, | |
|
stefan-webrtc
2016/02/09 14:02:20
video_rtp_drift?
danilchap
2016/02/09 14:56:49
Done.
| |
| 200 float video_ntp_drift) { | |
| 192 const char* kSyncGroup = "av_sync"; | 201 const char* kSyncGroup = "av_sync"; |
| 193 const uint32_t kAudioSendSsrc = 1234; | 202 const uint32_t kAudioSendSsrc = 1234; |
| 194 const uint32_t kAudioRecvSsrc = 5678; | 203 const uint32_t kAudioRecvSsrc = 5678; |
| 195 class AudioPacketReceiver : public PacketReceiver { | 204 class AudioPacketReceiver : public PacketReceiver { |
| 196 public: | 205 public: |
| 197 AudioPacketReceiver(int channel, VoENetwork* voe_network) | 206 AudioPacketReceiver(int channel, VoENetwork* voe_network) |
| 198 : channel_(channel), | 207 : channel_(channel), |
| 199 voe_network_(voe_network), | 208 voe_network_(voe_network), |
| 200 parser_(RtpHeaderParser::Create()) {} | 209 parser_(RtpHeaderParser::Create()) {} |
| 201 DeliveryStatus DeliverPacket(MediaType media_type, | 210 DeliveryStatus DeliverPacket(MediaType media_type, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 222 | 231 |
| 223 VoiceEngine* voice_engine = VoiceEngine::Create(); | 232 VoiceEngine* voice_engine = VoiceEngine::Create(); |
| 224 VoEBase* voe_base = VoEBase::GetInterface(voice_engine); | 233 VoEBase* voe_base = VoEBase::GetInterface(voice_engine); |
| 225 VoECodec* voe_codec = VoECodec::GetInterface(voice_engine); | 234 VoECodec* voe_codec = VoECodec::GetInterface(voice_engine); |
| 226 VoENetwork* voe_network = VoENetwork::GetInterface(voice_engine); | 235 VoENetwork* voe_network = VoENetwork::GetInterface(voice_engine); |
| 227 VoEVideoSync* voe_sync = VoEVideoSync::GetInterface(voice_engine); | 236 VoEVideoSync* voe_sync = VoEVideoSync::GetInterface(voice_engine); |
| 228 const std::string audio_filename = | 237 const std::string audio_filename = |
| 229 test::ResourcePath("voice_engine/audio_long16", "pcm"); | 238 test::ResourcePath("voice_engine/audio_long16", "pcm"); |
| 230 ASSERT_STRNE("", audio_filename.c_str()); | 239 ASSERT_STRNE("", audio_filename.c_str()); |
| 231 test::FakeAudioDevice fake_audio_device(Clock::GetRealTimeClock(), | 240 test::FakeAudioDevice fake_audio_device(Clock::GetRealTimeClock(), |
| 232 audio_filename); | 241 audio_filename, audio_rt_drift); |
| 233 EXPECT_EQ(0, voe_base->Init(&fake_audio_device, nullptr)); | 242 EXPECT_EQ(0, voe_base->Init(&fake_audio_device, nullptr)); |
| 234 Config voe_config; | 243 Config voe_config; |
| 235 voe_config.Set<VoicePacing>(new VoicePacing(true)); | 244 voe_config.Set<VoicePacing>(new VoicePacing(true)); |
| 236 int send_channel_id = voe_base->CreateChannel(voe_config); | 245 int send_channel_id = voe_base->CreateChannel(voe_config); |
| 237 int recv_channel_id = voe_base->CreateChannel(); | 246 int recv_channel_id = voe_base->CreateChannel(); |
| 238 | 247 |
| 239 SyncRtcpObserver audio_observer; | 248 SyncRtcpObserver audio_observer; |
| 240 | 249 |
| 241 AudioState::Config send_audio_state_config; | 250 AudioState::Config send_audio_state_config; |
| 242 send_audio_state_config.voice_engine = voice_engine; | 251 send_audio_state_config.voice_engine = voice_engine; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 if (create_audio_first) { | 326 if (create_audio_first) { |
| 318 audio_receive_stream = | 327 audio_receive_stream = |
| 319 receiver_call_->CreateAudioReceiveStream(audio_recv_config); | 328 receiver_call_->CreateAudioReceiveStream(audio_recv_config); |
| 320 CreateVideoStreams(); | 329 CreateVideoStreams(); |
| 321 } else { | 330 } else { |
| 322 CreateVideoStreams(); | 331 CreateVideoStreams(); |
| 323 audio_receive_stream = | 332 audio_receive_stream = |
| 324 receiver_call_->CreateAudioReceiveStream(audio_recv_config); | 333 receiver_call_->CreateAudioReceiveStream(audio_recv_config); |
| 325 } | 334 } |
| 326 | 335 |
| 327 CreateFrameGeneratorCapturer(); | 336 test::DriftingClock drifting_clock(clock_, video_ntp_drift); |
| 337 if (video_ntp_drift == 0 && video_rt_drift == 0) { | |
| 338 CreateFrameGeneratorCapturer(); | |
| 339 } else { | |
| 340 CreateFrameGeneratorCapturerWithDrift(&drifting_clock, video_rt_drift); | |
| 341 } | |
| 328 | 342 |
| 329 Start(); | 343 Start(); |
| 330 | 344 |
| 331 fake_audio_device.Start(); | 345 fake_audio_device.Start(); |
| 332 EXPECT_EQ(0, voe_base->StartPlayout(recv_channel_id)); | 346 EXPECT_EQ(0, voe_base->StartPlayout(recv_channel_id)); |
| 333 EXPECT_EQ(0, voe_base->StartReceive(recv_channel_id)); | 347 EXPECT_EQ(0, voe_base->StartReceive(recv_channel_id)); |
| 334 EXPECT_EQ(0, voe_base->StartSend(send_channel_id)); | 348 EXPECT_EQ(0, voe_base->StartSend(send_channel_id)); |
| 335 | 349 |
| 336 EXPECT_TRUE(observer.Wait()) | 350 EXPECT_TRUE(observer.Wait()) |
| 337 << "Timed out while waiting for audio and video to be synchronized."; | 351 << "Timed out while waiting for audio and video to be synchronized."; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 358 voe_codec->Release(); | 372 voe_codec->Release(); |
| 359 voe_network->Release(); | 373 voe_network->Release(); |
| 360 voe_sync->Release(); | 374 voe_sync->Release(); |
| 361 | 375 |
| 362 DestroyCalls(); | 376 DestroyCalls(); |
| 363 | 377 |
| 364 VoiceEngine::Delete(voice_engine); | 378 VoiceEngine::Delete(voice_engine); |
| 365 } | 379 } |
| 366 | 380 |
| 367 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioCreatedFirst) { | 381 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioCreatedFirst) { |
| 368 TestAudioVideoSync(false, true); | 382 TestAudioVideoSync(false, true, 0, 0, 0); |
| 369 } | 383 } |
| 370 | 384 |
| 371 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoCreatedFirst) { | 385 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoCreatedFirst) { |
| 372 TestAudioVideoSync(false, false); | 386 TestAudioVideoSync(false, false, 0, 0, 0); |
| 373 } | 387 } |
| 374 | 388 |
| 375 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithFec) { | 389 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithFec) { |
| 376 TestAudioVideoSync(true, false); | 390 TestAudioVideoSync(true, false, 0, 0, 0); |
| 391 } | |
| 392 | |
| 393 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithNtpDrift) { | |
| 394 TestAudioVideoSync(false, true, 0, 0, .02); | |
| 395 } | |
| 396 | |
| 397 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithRtDrift) { | |
|
stefan-webrtc
2016/02/09 14:02:20
Add DISABLED_ in front of failing tests for now so
danilchap
2016/02/09 14:56:49
Done.
pbos-webrtc
2016/02/09 15:14:46
WithRtDrift?
| |
| 398 TestAudioVideoSync(false, true, -.3, .3, 0); | |
|
stefan-webrtc
2016/02/09 14:02:20
What about a test case where only audio drifts and
danilchap
2016/02/09 14:56:49
Those are weeker than Audio and Video drifting opp
pbos-webrtc
2016/02/09 15:14:46
What about a case where video is slower than audio
danilchap
2016/02/09 15:28:43
It pass too.
| |
| 377 } | 399 } |
| 378 | 400 |
| 379 void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, | 401 void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, |
| 380 int threshold_ms, | 402 int threshold_ms, |
| 381 int start_time_ms, | 403 int start_time_ms, |
| 382 int run_time_ms) { | 404 int run_time_ms) { |
| 383 class CaptureNtpTimeObserver : public test::EndToEndTest, | 405 class CaptureNtpTimeObserver : public test::EndToEndTest, |
| 384 public VideoRenderer { | 406 public VideoRenderer { |
| 385 public: | 407 public: |
| 386 CaptureNtpTimeObserver(const FakeNetworkPipe::Config& net_config, | 408 CaptureNtpTimeObserver(const FakeNetworkPipe::Config& net_config, |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 749 int encoder_inits_; | 771 int encoder_inits_; |
| 750 uint32_t last_set_bitrate_; | 772 uint32_t last_set_bitrate_; |
| 751 VideoSendStream* send_stream_; | 773 VideoSendStream* send_stream_; |
| 752 VideoEncoderConfig encoder_config_; | 774 VideoEncoderConfig encoder_config_; |
| 753 } test; | 775 } test; |
| 754 | 776 |
| 755 RunBaseTest(&test); | 777 RunBaseTest(&test); |
| 756 } | 778 } |
| 757 | 779 |
| 758 } // namespace webrtc | 780 } // namespace webrtc |
| OLD | NEW |