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 |
45 using webrtc::test::DriftingClock; | |
46 using webrtc::test::FakeAudioDevice; | |
47 | |
44 namespace webrtc { | 48 namespace webrtc { |
45 | 49 |
46 class CallPerfTest : public test::CallTest { | 50 class CallPerfTest : public test::CallTest { |
47 protected: | 51 protected: |
48 void TestAudioVideoSync(bool fec, bool create_audio_first); | 52 void TestAudioVideoSync(bool fec, |
53 bool create_audio_first, | |
54 float video_ntp_speed, | |
55 float video_rtp_speed, | |
56 float audio_rtp_speed); | |
49 | 57 |
50 void TestCpuOveruse(LoadObserver::Load tested_load, int encode_delay_ms); | 58 void TestCpuOveruse(LoadObserver::Load tested_load, int encode_delay_ms); |
51 | 59 |
52 void TestMinTransmitBitrate(bool pad_to_min_bitrate); | 60 void TestMinTransmitBitrate(bool pad_to_min_bitrate); |
53 | 61 |
54 void TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, | 62 void TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, |
55 int threshold_ms, | 63 int threshold_ms, |
56 int start_time_ms, | 64 int start_time_ms, |
57 int run_time_ms); | 65 int run_time_ms); |
58 }; | 66 }; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 | 189 |
182 private: | 190 private: |
183 Clock* const clock_; | 191 Clock* const clock_; |
184 const int voe_channel_; | 192 const int voe_channel_; |
185 VoEVideoSync* const voe_sync_; | 193 VoEVideoSync* const voe_sync_; |
186 SyncRtcpObserver* const audio_observer_; | 194 SyncRtcpObserver* const audio_observer_; |
187 const int64_t creation_time_ms_; | 195 const int64_t creation_time_ms_; |
188 int64_t first_time_in_sync_; | 196 int64_t first_time_in_sync_; |
189 }; | 197 }; |
190 | 198 |
191 void CallPerfTest::TestAudioVideoSync(bool fec, bool create_audio_first) { | 199 void CallPerfTest::TestAudioVideoSync(bool fec, |
200 bool create_audio_first, | |
201 float video_ntp_speed, | |
202 float video_rtp_speed, | |
203 float audio_rtp_speed) { | |
192 const char* kSyncGroup = "av_sync"; | 204 const char* kSyncGroup = "av_sync"; |
193 const uint32_t kAudioSendSsrc = 1234; | 205 const uint32_t kAudioSendSsrc = 1234; |
194 const uint32_t kAudioRecvSsrc = 5678; | 206 const uint32_t kAudioRecvSsrc = 5678; |
195 class AudioPacketReceiver : public PacketReceiver { | 207 class AudioPacketReceiver : public PacketReceiver { |
196 public: | 208 public: |
197 AudioPacketReceiver(int channel, VoENetwork* voe_network) | 209 AudioPacketReceiver(int channel, VoENetwork* voe_network) |
198 : channel_(channel), | 210 : channel_(channel), |
199 voe_network_(voe_network), | 211 voe_network_(voe_network), |
200 parser_(RtpHeaderParser::Create()) {} | 212 parser_(RtpHeaderParser::Create()) {} |
201 DeliveryStatus DeliverPacket(MediaType media_type, | 213 DeliveryStatus DeliverPacket(MediaType media_type, |
(...skipping 19 matching lines...) Expand all Loading... | |
221 }; | 233 }; |
222 | 234 |
223 VoiceEngine* voice_engine = VoiceEngine::Create(); | 235 VoiceEngine* voice_engine = VoiceEngine::Create(); |
224 VoEBase* voe_base = VoEBase::GetInterface(voice_engine); | 236 VoEBase* voe_base = VoEBase::GetInterface(voice_engine); |
225 VoECodec* voe_codec = VoECodec::GetInterface(voice_engine); | 237 VoECodec* voe_codec = VoECodec::GetInterface(voice_engine); |
226 VoENetwork* voe_network = VoENetwork::GetInterface(voice_engine); | 238 VoENetwork* voe_network = VoENetwork::GetInterface(voice_engine); |
227 VoEVideoSync* voe_sync = VoEVideoSync::GetInterface(voice_engine); | 239 VoEVideoSync* voe_sync = VoEVideoSync::GetInterface(voice_engine); |
228 const std::string audio_filename = | 240 const std::string audio_filename = |
229 test::ResourcePath("voice_engine/audio_long16", "pcm"); | 241 test::ResourcePath("voice_engine/audio_long16", "pcm"); |
230 ASSERT_STRNE("", audio_filename.c_str()); | 242 ASSERT_STRNE("", audio_filename.c_str()); |
231 test::FakeAudioDevice fake_audio_device(Clock::GetRealTimeClock(), | 243 FakeAudioDevice fake_audio_device(Clock::GetRealTimeClock(), audio_filename, |
232 audio_filename); | 244 audio_rtp_speed); |
233 EXPECT_EQ(0, voe_base->Init(&fake_audio_device, nullptr)); | 245 EXPECT_EQ(0, voe_base->Init(&fake_audio_device, nullptr)); |
234 Config voe_config; | 246 Config voe_config; |
235 voe_config.Set<VoicePacing>(new VoicePacing(true)); | 247 voe_config.Set<VoicePacing>(new VoicePacing(true)); |
236 int send_channel_id = voe_base->CreateChannel(voe_config); | 248 int send_channel_id = voe_base->CreateChannel(voe_config); |
237 int recv_channel_id = voe_base->CreateChannel(); | 249 int recv_channel_id = voe_base->CreateChannel(); |
238 | 250 |
239 SyncRtcpObserver audio_observer; | 251 SyncRtcpObserver audio_observer; |
240 | 252 |
241 AudioState::Config send_audio_state_config; | 253 AudioState::Config send_audio_state_config; |
242 send_audio_state_config.voice_engine = voice_engine; | 254 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) { | 329 if (create_audio_first) { |
318 audio_receive_stream = | 330 audio_receive_stream = |
319 receiver_call_->CreateAudioReceiveStream(audio_recv_config); | 331 receiver_call_->CreateAudioReceiveStream(audio_recv_config); |
320 CreateVideoStreams(); | 332 CreateVideoStreams(); |
321 } else { | 333 } else { |
322 CreateVideoStreams(); | 334 CreateVideoStreams(); |
323 audio_receive_stream = | 335 audio_receive_stream = |
324 receiver_call_->CreateAudioReceiveStream(audio_recv_config); | 336 receiver_call_->CreateAudioReceiveStream(audio_recv_config); |
325 } | 337 } |
326 | 338 |
327 CreateFrameGeneratorCapturer(); | 339 DriftingClock drifting_clock(clock_, video_ntp_speed); |
pbos-webrtc
2016/02/10 13:28:13
Shouldn't we always use the one with drift, even i
danilchap
2016/02/10 15:50:19
Done. This test expected to work with large drift,
| |
340 if (video_ntp_speed == DriftingClock::kNoDrift && | |
341 video_rtp_speed == DriftingClock::kNoDrift) { | |
342 CreateFrameGeneratorCapturer(); | |
343 } else { | |
344 CreateFrameGeneratorCapturerWithDrift(&drifting_clock, video_rtp_speed); | |
345 } | |
328 | 346 |
329 Start(); | 347 Start(); |
330 | 348 |
331 fake_audio_device.Start(); | 349 fake_audio_device.Start(); |
332 EXPECT_EQ(0, voe_base->StartPlayout(recv_channel_id)); | 350 EXPECT_EQ(0, voe_base->StartPlayout(recv_channel_id)); |
333 EXPECT_EQ(0, voe_base->StartReceive(recv_channel_id)); | 351 EXPECT_EQ(0, voe_base->StartReceive(recv_channel_id)); |
334 EXPECT_EQ(0, voe_base->StartSend(send_channel_id)); | 352 EXPECT_EQ(0, voe_base->StartSend(send_channel_id)); |
335 | 353 |
336 EXPECT_TRUE(observer.Wait()) | 354 EXPECT_TRUE(observer.Wait()) |
337 << "Timed out while waiting for audio and video to be synchronized."; | 355 << "Timed out while waiting for audio and video to be synchronized."; |
(...skipping 20 matching lines...) Expand all Loading... | |
358 voe_codec->Release(); | 376 voe_codec->Release(); |
359 voe_network->Release(); | 377 voe_network->Release(); |
360 voe_sync->Release(); | 378 voe_sync->Release(); |
361 | 379 |
362 DestroyCalls(); | 380 DestroyCalls(); |
363 | 381 |
364 VoiceEngine::Delete(voice_engine); | 382 VoiceEngine::Delete(voice_engine); |
365 } | 383 } |
366 | 384 |
367 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioCreatedFirst) { | 385 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioCreatedFirst) { |
368 TestAudioVideoSync(false, true); | 386 TestAudioVideoSync(false, true, DriftingClock::kNoDrift, |
387 DriftingClock::kNoDrift, DriftingClock::kNoDrift); | |
369 } | 388 } |
370 | 389 |
371 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoCreatedFirst) { | 390 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoCreatedFirst) { |
372 TestAudioVideoSync(false, false); | 391 TestAudioVideoSync(false, false, DriftingClock::kNoDrift, |
392 DriftingClock::kNoDrift, DriftingClock::kNoDrift); | |
373 } | 393 } |
374 | 394 |
375 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithFec) { | 395 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithFec) { |
376 TestAudioVideoSync(true, false); | 396 TestAudioVideoSync(true, false, DriftingClock::kNoDrift, |
397 DriftingClock::kNoDrift, DriftingClock::kNoDrift); | |
398 } | |
399 | |
400 // TODO(danilchap): Reenable after adding support for frame capture clock | |
401 // that is not in sync with local TickTime clock. | |
402 TEST_F(CallPerfTest, DISABLED_PlaysOutAudioAndVideoInSyncWithVideoNtpDrift) { | |
403 TestAudioVideoSync(false, true, DriftingClock::PercentsFaster(10.0f), | |
404 DriftingClock::kNoDrift, DriftingClock::kNoDrift); | |
405 } | |
406 | |
407 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioRtpDrift) { | |
408 TestAudioVideoSync(false, true, DriftingClock::kNoDrift, | |
409 DriftingClock::kNoDrift, | |
410 DriftingClock::PercentsFaster(30.0f)); | |
411 } | |
412 | |
413 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoRtpDrift) { | |
414 TestAudioVideoSync(false, true, DriftingClock::kNoDrift, | |
415 DriftingClock::PercentsFaster(30.0f), | |
416 DriftingClock::kNoDrift); | |
417 } | |
418 | |
419 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioFasterThanVideoDrift) { | |
420 TestAudioVideoSync(false, true, DriftingClock::kNoDrift, | |
421 DriftingClock::PercentsSlower(30.0f), | |
422 DriftingClock::PercentsFaster(30.0f)); | |
423 } | |
424 | |
425 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoFasterThanAudioDrift) { | |
426 TestAudioVideoSync(false, true, DriftingClock::kNoDrift, | |
427 DriftingClock::PercentsFaster(30.0f), | |
428 DriftingClock::PercentsSlower(30.0f)); | |
377 } | 429 } |
378 | 430 |
379 void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, | 431 void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, |
380 int threshold_ms, | 432 int threshold_ms, |
381 int start_time_ms, | 433 int start_time_ms, |
382 int run_time_ms) { | 434 int run_time_ms) { |
383 class CaptureNtpTimeObserver : public test::EndToEndTest, | 435 class CaptureNtpTimeObserver : public test::EndToEndTest, |
384 public VideoRenderer { | 436 public VideoRenderer { |
385 public: | 437 public: |
386 CaptureNtpTimeObserver(const FakeNetworkPipe::Config& net_config, | 438 CaptureNtpTimeObserver(const FakeNetworkPipe::Config& net_config, |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
749 int encoder_inits_; | 801 int encoder_inits_; |
750 uint32_t last_set_bitrate_; | 802 uint32_t last_set_bitrate_; |
751 VideoSendStream* send_stream_; | 803 VideoSendStream* send_stream_; |
752 VideoEncoderConfig encoder_config_; | 804 VideoEncoderConfig encoder_config_; |
753 } test; | 805 } test; |
754 | 806 |
755 RunBaseTest(&test); | 807 RunBaseTest(&test); |
756 } | 808 } |
757 | 809 |
758 } // namespace webrtc | 810 } // namespace webrtc |
OLD | NEW |