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_rtp_drift, | |
pbos-webrtc
2016/02/09 20:42:24
..drift_factor (and use 1.03 and .97 for instance)
danilchap
2016/02/10 12:40:35
renamed to speed. Using values like 1.3 and .7 now
| |
52 float video_rtp_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_rtp_drift, | |
199 float video_rtp_drift, | |
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_rtp_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_rtp_drift == 0) { | |
338 CreateFrameGeneratorCapturer(); | |
339 } else { | |
340 CreateFrameGeneratorCapturerWithDrift(&drifting_clock, video_rtp_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, DISABLED_PlaysOutAudioAndVideoInSyncWithVideoNtpDrift) { | |
pbos-webrtc
2016/02/09 20:42:24
put a TODO(danilchap): to enable it here with a re
danilchap
2016/02/10 12:40:35
Done.
| |
394 TestAudioVideoSync(false, true, 0, 0, 0.02f); | |
395 } | |
396 | |
397 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioRtpDrift) { | |
pbos-webrtc
2016/02/09 20:42:24
If we can have more aggressive percentages here (o
danilchap
2016/02/10 12:40:35
0.3 means 30%. Abstract constants replaced with so
| |
398 TestAudioVideoSync(false, true, 0.3f, 0, 0); | |
399 } | |
400 | |
401 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoRtpDrift) { | |
402 TestAudioVideoSync(false, true, 0, 0.3f, 0); | |
403 } | |
404 | |
405 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioFasterThanVideoDrift) { | |
406 TestAudioVideoSync(false, true, -0.3f, 0.3f, 0); | |
407 } | |
408 | |
409 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoFasterThanAudioDrift) { | |
410 TestAudioVideoSync(false, true, 0.3f, -0.3f, 0); | |
377 } | 411 } |
378 | 412 |
379 void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, | 413 void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, |
380 int threshold_ms, | 414 int threshold_ms, |
381 int start_time_ms, | 415 int start_time_ms, |
382 int run_time_ms) { | 416 int run_time_ms) { |
383 class CaptureNtpTimeObserver : public test::EndToEndTest, | 417 class CaptureNtpTimeObserver : public test::EndToEndTest, |
384 public VideoRenderer { | 418 public VideoRenderer { |
385 public: | 419 public: |
386 CaptureNtpTimeObserver(const FakeNetworkPipe::Config& net_config, | 420 CaptureNtpTimeObserver(const FakeNetworkPipe::Config& net_config, |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
749 int encoder_inits_; | 783 int encoder_inits_; |
750 uint32_t last_set_bitrate_; | 784 uint32_t last_set_bitrate_; |
751 VideoSendStream* send_stream_; | 785 VideoSendStream* send_stream_; |
752 VideoEncoderConfig encoder_config_; | 786 VideoEncoderConfig encoder_config_; |
753 } test; | 787 } test; |
754 | 788 |
755 RunBaseTest(&test); | 789 RunBaseTest(&test); |
756 } | 790 } |
757 | 791 |
758 } // namespace webrtc | 792 } // namespace webrtc |
OLD | NEW |