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> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" | 42 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" |
43 #include "webrtc/voice_engine/include/voe_video_sync.h" | 43 #include "webrtc/voice_engine/include/voe_video_sync.h" |
44 | 44 |
45 using webrtc::test::DriftingClock; | 45 using webrtc::test::DriftingClock; |
46 using webrtc::test::FakeAudioDevice; | 46 using webrtc::test::FakeAudioDevice; |
47 | 47 |
48 namespace webrtc { | 48 namespace webrtc { |
49 | 49 |
50 class CallPerfTest : public test::CallTest { | 50 class CallPerfTest : public test::CallTest { |
51 protected: | 51 protected: |
52 void TestAudioVideoSync(bool fec, | 52 enum class FecMode { |
53 bool create_audio_first, | 53 kOn, kOff |
| 54 }; |
| 55 enum class CreateOrder { |
| 56 kAudioFirst, kVideoFirst |
| 57 }; |
| 58 void TestAudioVideoSync(FecMode fec, |
| 59 CreateOrder create_first, |
54 float video_ntp_speed, | 60 float video_ntp_speed, |
55 float video_rtp_speed, | 61 float video_rtp_speed, |
56 float audio_rtp_speed); | 62 float audio_rtp_speed); |
57 | 63 |
58 void TestCpuOveruse(LoadObserver::Load tested_load, int encode_delay_ms); | 64 void TestCpuOveruse(LoadObserver::Load tested_load, int encode_delay_ms); |
59 | 65 |
60 void TestMinTransmitBitrate(bool pad_to_min_bitrate); | 66 void TestMinTransmitBitrate(bool pad_to_min_bitrate); |
61 | 67 |
62 void TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, | 68 void TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, |
63 int threshold_ms, | 69 int threshold_ms, |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 195 |
190 private: | 196 private: |
191 Clock* const clock_; | 197 Clock* const clock_; |
192 const int voe_channel_; | 198 const int voe_channel_; |
193 VoEVideoSync* const voe_sync_; | 199 VoEVideoSync* const voe_sync_; |
194 SyncRtcpObserver* const audio_observer_; | 200 SyncRtcpObserver* const audio_observer_; |
195 const int64_t creation_time_ms_; | 201 const int64_t creation_time_ms_; |
196 int64_t first_time_in_sync_; | 202 int64_t first_time_in_sync_; |
197 }; | 203 }; |
198 | 204 |
199 void CallPerfTest::TestAudioVideoSync(bool fec, | 205 void CallPerfTest::TestAudioVideoSync(FecMode fec, |
200 bool create_audio_first, | 206 CreateOrder create_first, |
201 float video_ntp_speed, | 207 float video_ntp_speed, |
202 float video_rtp_speed, | 208 float video_rtp_speed, |
203 float audio_rtp_speed) { | 209 float audio_rtp_speed) { |
204 const char* kSyncGroup = "av_sync"; | 210 const char* kSyncGroup = "av_sync"; |
205 const uint32_t kAudioSendSsrc = 1234; | 211 const uint32_t kAudioSendSsrc = 1234; |
206 const uint32_t kAudioRecvSsrc = 5678; | 212 const uint32_t kAudioRecvSsrc = 5678; |
207 class AudioPacketReceiver : public PacketReceiver { | 213 class AudioPacketReceiver : public PacketReceiver { |
208 public: | 214 public: |
209 AudioPacketReceiver(int channel, VoENetwork* voe_network) | 215 AudioPacketReceiver(int channel, VoENetwork* voe_network) |
210 : channel_(channel), | 216 : channel_(channel), |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 AudioSendStream::Config audio_send_config(&audio_send_transport); | 307 AudioSendStream::Config audio_send_config(&audio_send_transport); |
302 audio_send_config.voe_channel_id = send_channel_id; | 308 audio_send_config.voe_channel_id = send_channel_id; |
303 audio_send_config.rtp.ssrc = kAudioSendSsrc; | 309 audio_send_config.rtp.ssrc = kAudioSendSsrc; |
304 AudioSendStream* audio_send_stream = | 310 AudioSendStream* audio_send_stream = |
305 sender_call_->CreateAudioSendStream(audio_send_config); | 311 sender_call_->CreateAudioSendStream(audio_send_config); |
306 | 312 |
307 CodecInst isac = {103, "ISAC", 16000, 480, 1, 32000}; | 313 CodecInst isac = {103, "ISAC", 16000, 480, 1, 32000}; |
308 EXPECT_EQ(0, voe_codec->SetSendCodec(send_channel_id, isac)); | 314 EXPECT_EQ(0, voe_codec->SetSendCodec(send_channel_id, isac)); |
309 | 315 |
310 video_send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | 316 video_send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
311 if (fec) { | 317 if (fec == FecMode::kOn) { |
312 video_send_config_.rtp.fec.red_payload_type = kRedPayloadType; | 318 video_send_config_.rtp.fec.red_payload_type = kRedPayloadType; |
313 video_send_config_.rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; | 319 video_send_config_.rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; |
314 video_receive_configs_[0].rtp.fec.red_payload_type = kRedPayloadType; | 320 video_receive_configs_[0].rtp.fec.red_payload_type = kRedPayloadType; |
315 video_receive_configs_[0].rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; | 321 video_receive_configs_[0].rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; |
316 } | 322 } |
317 video_receive_configs_[0].rtp.nack.rtp_history_ms = 1000; | 323 video_receive_configs_[0].rtp.nack.rtp_history_ms = 1000; |
318 video_receive_configs_[0].renderer = &observer; | 324 video_receive_configs_[0].renderer = &observer; |
319 video_receive_configs_[0].sync_group = kSyncGroup; | 325 video_receive_configs_[0].sync_group = kSyncGroup; |
320 | 326 |
321 AudioReceiveStream::Config audio_recv_config; | 327 AudioReceiveStream::Config audio_recv_config; |
322 audio_recv_config.rtp.remote_ssrc = kAudioSendSsrc; | 328 audio_recv_config.rtp.remote_ssrc = kAudioSendSsrc; |
323 audio_recv_config.rtp.local_ssrc = kAudioRecvSsrc; | 329 audio_recv_config.rtp.local_ssrc = kAudioRecvSsrc; |
324 audio_recv_config.voe_channel_id = recv_channel_id; | 330 audio_recv_config.voe_channel_id = recv_channel_id; |
325 audio_recv_config.sync_group = kSyncGroup; | 331 audio_recv_config.sync_group = kSyncGroup; |
326 | 332 |
327 AudioReceiveStream* audio_receive_stream; | 333 AudioReceiveStream* audio_receive_stream; |
328 | 334 |
329 if (create_audio_first) { | 335 if (create_first == CreateOrder::kAudioFirst) { |
330 audio_receive_stream = | 336 audio_receive_stream = |
331 receiver_call_->CreateAudioReceiveStream(audio_recv_config); | 337 receiver_call_->CreateAudioReceiveStream(audio_recv_config); |
332 CreateVideoStreams(); | 338 CreateVideoStreams(); |
333 } else { | 339 } else { |
334 CreateVideoStreams(); | 340 CreateVideoStreams(); |
335 audio_receive_stream = | 341 audio_receive_stream = |
336 receiver_call_->CreateAudioReceiveStream(audio_recv_config); | 342 receiver_call_->CreateAudioReceiveStream(audio_recv_config); |
337 } | 343 } |
338 | 344 |
339 DriftingClock drifting_clock(clock_, video_ntp_speed); | 345 DriftingClock drifting_clock(clock_, video_ntp_speed); |
(...skipping 30 matching lines...) Expand all Loading... |
370 voe_base->Release(); | 376 voe_base->Release(); |
371 voe_codec->Release(); | 377 voe_codec->Release(); |
372 voe_network->Release(); | 378 voe_network->Release(); |
373 voe_sync->Release(); | 379 voe_sync->Release(); |
374 | 380 |
375 DestroyCalls(); | 381 DestroyCalls(); |
376 | 382 |
377 VoiceEngine::Delete(voice_engine); | 383 VoiceEngine::Delete(voice_engine); |
378 } | 384 } |
379 | 385 |
380 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioCreatedFirst) { | |
381 TestAudioVideoSync(false, true, DriftingClock::kNoDrift, | |
382 DriftingClock::kNoDrift, DriftingClock::kNoDrift); | |
383 } | |
384 | |
385 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoCreatedFirst) { | |
386 TestAudioVideoSync(false, false, DriftingClock::kNoDrift, | |
387 DriftingClock::kNoDrift, DriftingClock::kNoDrift); | |
388 } | |
389 | |
390 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithFec) { | |
391 TestAudioVideoSync(true, false, DriftingClock::kNoDrift, | |
392 DriftingClock::kNoDrift, DriftingClock::kNoDrift); | |
393 } | |
394 | |
395 // TODO(danilchap): Reenable after adding support for frame capture clock | 386 // TODO(danilchap): Reenable after adding support for frame capture clock |
396 // that is not in sync with local TickTime clock. | 387 // that is not in sync with local TickTime clock. |
397 TEST_F(CallPerfTest, DISABLED_PlaysOutAudioAndVideoInSyncWithVideoNtpDrift) { | 388 TEST_F(CallPerfTest, DISABLED_PlaysOutAudioAndVideoInSyncWithVideoNtpDrift) { |
398 TestAudioVideoSync(false, true, DriftingClock::PercentsFaster(10.0f), | 389 TestAudioVideoSync(FecMode::kOff, CreateOrder::kAudioFirst, |
| 390 DriftingClock::PercentsFaster(10.0f), |
399 DriftingClock::kNoDrift, DriftingClock::kNoDrift); | 391 DriftingClock::kNoDrift, DriftingClock::kNoDrift); |
400 } | 392 } |
401 | 393 |
402 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioRtpDrift) { | 394 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioFasterThanVideoDrift) { |
403 TestAudioVideoSync(false, true, DriftingClock::kNoDrift, | 395 TestAudioVideoSync(FecMode::kOff, CreateOrder::kAudioFirst, |
404 DriftingClock::kNoDrift, | 396 DriftingClock::kNoDrift, |
405 DriftingClock::PercentsFaster(30.0f)); | |
406 } | |
407 | |
408 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoRtpDrift) { | |
409 TestAudioVideoSync(false, true, DriftingClock::kNoDrift, | |
410 DriftingClock::PercentsFaster(30.0f), | |
411 DriftingClock::kNoDrift); | |
412 } | |
413 | |
414 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioFasterThanVideoDrift) { | |
415 TestAudioVideoSync(false, true, DriftingClock::kNoDrift, | |
416 DriftingClock::PercentsSlower(30.0f), | 397 DriftingClock::PercentsSlower(30.0f), |
417 DriftingClock::PercentsFaster(30.0f)); | 398 DriftingClock::PercentsFaster(30.0f)); |
418 } | 399 } |
419 | 400 |
420 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoFasterThanAudioDrift) { | 401 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoFasterThanAudioDrift) { |
421 TestAudioVideoSync(false, true, DriftingClock::kNoDrift, | 402 TestAudioVideoSync(FecMode::kOn, CreateOrder::kVideoFirst, |
| 403 DriftingClock::kNoDrift, |
422 DriftingClock::PercentsFaster(30.0f), | 404 DriftingClock::PercentsFaster(30.0f), |
423 DriftingClock::PercentsSlower(30.0f)); | 405 DriftingClock::PercentsSlower(30.0f)); |
424 } | 406 } |
425 | 407 |
426 void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, | 408 void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, |
427 int threshold_ms, | 409 int threshold_ms, |
428 int start_time_ms, | 410 int start_time_ms, |
429 int run_time_ms) { | 411 int run_time_ms) { |
430 class CaptureNtpTimeObserver : public test::EndToEndTest, | 412 class CaptureNtpTimeObserver : public test::EndToEndTest, |
431 public VideoRenderer { | 413 public VideoRenderer { |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 int encoder_inits_; | 778 int encoder_inits_; |
797 uint32_t last_set_bitrate_; | 779 uint32_t last_set_bitrate_; |
798 VideoSendStream* send_stream_; | 780 VideoSendStream* send_stream_; |
799 VideoEncoderConfig encoder_config_; | 781 VideoEncoderConfig encoder_config_; |
800 } test; | 782 } test; |
801 | 783 |
802 RunBaseTest(&test); | 784 RunBaseTest(&test); |
803 } | 785 } |
804 | 786 |
805 } // namespace webrtc | 787 } // namespace webrtc |
OLD | NEW |